Files
universal_ble/example/lib/data/storage_service.dart
T
Rohit Sangwan 895dcbe343 Improve example app UI (#193)
* Improve example app ui

* Store favorite services in local storage

* Use Text instead of SelectableText

* Improve colors

* Fix flutter analyzer issues

* Revert example app minimum sdk requirement

* Implement hasPermission api and improve ui flow

* More ui improvements

* Improve ScannedItem ui

* Improve control ui

* Change color theme to blue

* Minor improvements wip

* improve responsive ui and flow

* More improvements

* More improvements

* Update Mac podfile

* Fix home page scroll view

* Update app and package name

* Revert changelog

* Resolve Ai comments

---------

Co-authored-by: Foti Dim <foti@navideck.com>
2025-12-21 08:51:36 +01:00

23 lines
675 B
Dart

import 'package:shared_preferences/shared_preferences.dart';
class StorageService {
StorageService._();
static StorageService? _instance;
static StorageService get instance => _instance ??= StorageService._();
late SharedPreferencesWithCache _preferences;
Future<void> init() async {
_preferences = await SharedPreferencesWithCache.create(
cacheOptions: const SharedPreferencesWithCacheOptions(),
);
}
Future<void> setFavoriteServices(List<String> services) async {
await _preferences.setStringList('favorite_services', services);
}
List<String> getFavoriteServices() =>
_preferences.getStringList('favorite_services') ?? [];
}