8c75e3965f
- Added a new `prefs_async.dart` file to encapsulate the usage of `SharedPreferencesAsync`. - Updated `ScanController`, `StorageService`, and `ScannerScreen` to utilize the new async preferences methods, enhancing performance and code clarity. - Modified `devtools_options.yaml` to enable the `shared_preferences` extension. - Refactored the `FlashOnUpdateWidget` to improve the outline animation and added a customizable border radius. - Adjusted the favorite services loading mechanism in `PeripheralDetailPage` to be asynchronous, ensuring better state management.
19 lines
591 B
Dart
19 lines
591 B
Dart
import 'package:universal_ble_example/data/prefs_async.dart';
|
|
|
|
class StorageService {
|
|
StorageService._();
|
|
static StorageService? _instance;
|
|
static StorageService get instance => _instance ??= StorageService._();
|
|
|
|
Future<void> init() async {
|
|
// SharedPreferencesAsync is used via prefsAsync; no async init needed.
|
|
}
|
|
|
|
Future<void> setFavoriteServices(List<String> services) async {
|
|
await prefsAsync.setStringList('favorite_services', services);
|
|
}
|
|
|
|
Future<List<String>> getFavoriteServices() async =>
|
|
(await prefsAsync.getStringList('favorite_services')) ?? [];
|
|
}
|