-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add local storage: sharedpreferences or hive
- Loading branch information
Truong Nhat Duy
committed
Oct 17, 2022
1 parent
b3636a4
commit 2986d8a
Showing
15 changed files
with
333 additions
and
19 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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,75 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:boilerplate/services/local_storage_service/shared_preferences_service.dart'; | ||
|
||
/// TODO: modify this if you use Hive packages | ||
class HiveService implements SharedPreferencesService { | ||
@override | ||
String isDarkModeKey = 'hiveIsDarkModeKey'; | ||
|
||
@override | ||
String isFirstUseKey = 'hiveIsFirstUseKey'; | ||
|
||
@override | ||
String localeKey = 'hiveLocaleKey'; | ||
|
||
@override | ||
String tokenKey = 'hiveTokenKey'; | ||
|
||
@override | ||
getValue({required String key}) { | ||
// TODO: implement getValue | ||
throw UnimplementedError(); | ||
} | ||
|
||
@override | ||
FutureOr<void> init() { | ||
// TODO: implement init | ||
throw UnimplementedError(); | ||
} | ||
|
||
@override | ||
// TODO: implement isDarkMode | ||
bool get isDarkMode => throw UnimplementedError(); | ||
|
||
@override | ||
// TODO: implement isFirstUse | ||
bool get isFirstUse => throw UnimplementedError(); | ||
|
||
@override | ||
// TODO: implement locale | ||
String get locale => throw UnimplementedError(); | ||
|
||
@override | ||
Future<bool> setIsDarkMode(bool isDarkMode) { | ||
// TODO: implement setIsDarkMode | ||
throw UnimplementedError(); | ||
} | ||
|
||
@override | ||
Future<bool> setIsFirstUse(bool isFirstUse) { | ||
// TODO: implement setIsFirstUse | ||
throw UnimplementedError(); | ||
} | ||
|
||
@override | ||
Future<bool> setLocale(String locale) { | ||
// TODO: implement setLocale | ||
throw UnimplementedError(); | ||
} | ||
|
||
@override | ||
Future<bool> setToken(String token) { | ||
// TODO: implement setToken | ||
throw UnimplementedError(); | ||
} | ||
|
||
@override | ||
void setValue({required String key, required value}) { | ||
// TODO: implement setValue | ||
} | ||
|
||
@override | ||
// TODO: implement token | ||
String? get token => throw UnimplementedError(); | ||
} |
23 changes: 23 additions & 0 deletions
23
lib/services/local_storage_service/local_storage_service.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,23 @@ | ||
import 'dart:async'; | ||
|
||
abstract class LocalStorageService { | ||
String tokenKey = ''; | ||
String localeKey = ''; | ||
String isDarkModeKey = ''; | ||
String isFirstUseKey = ''; | ||
|
||
FutureOr<void> init(); | ||
String? get token; | ||
String get locale; | ||
bool get isDarkMode; | ||
|
||
bool get isFirstUse; | ||
|
||
Future<bool> setToken(String token); | ||
Future<bool> setLocale(String locale); | ||
Future<bool> setIsDarkMode(bool isDarkMode); | ||
Future<bool> setIsFirstUse(bool isFirstUse); | ||
|
||
void setValue({required String key, required dynamic value}); | ||
dynamic getValue({required String key}); | ||
} |
Oops, something went wrong.