-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
lib/src/common/services/storage/shared_preferences_service_new.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
import 'storage_service.dart'; | ||
|
||
class SharedPreferencesServicesNew implements StorageService { | ||
SharedPreferencesServicesNew(this._sharedPreferences); | ||
final SharedPreferencesAsync _sharedPreferences; | ||
|
||
@override | ||
Future<void> remove(String key) async => await _sharedPreferences.remove(key); | ||
|
||
@override | ||
Future<String?> get(String key) async => | ||
await _sharedPreferences.getString(key); | ||
|
||
@override | ||
Future<void> set(String key, String data) async => | ||
await _sharedPreferences.setString(key, data.toString()); | ||
|
||
@override | ||
Future<void> clear() async => await _sharedPreferences.clear(); | ||
|
||
@override | ||
Future<bool> has(String key) async => | ||
await _sharedPreferences.containsKey(key) ? true : false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/// Storage service interface | ||
abstract class StorageService { | ||
Future<void> remove(String key); | ||
|
||
Future<String?> get(String key); | ||
|
||
Future<void> set(String key, String data); | ||
|
||
Future<void> clear(); | ||
|
||
Future<bool> has(String key); | ||
} |