generated from xmartlabs/flutter-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added clean data * Resolve comments * Resolve comments
- Loading branch information
1 parent
2abf934
commit b09981a
Showing
12 changed files
with
105 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,11 +28,18 @@ extension EnviromentPath on Environments { | |
} | ||
|
||
abstract class Config { | ||
static const debugMode = kDebugMode; | ||
static const firebaseEnabled = !debugMode; | ||
static const analyticsEnabled = !debugMode; | ||
static const crashlyticsEnabled = !debugMode; | ||
static bool bugseeEnabled = !debugMode && _environment == Environments.dev; | ||
|
||
static const String _environmentFolder = 'environments'; | ||
static final num maxDatabaseIntValue = pow(2, 32) - 1; | ||
static const Duration durationAnimation = Duration(milliseconds: 150); | ||
static const Duration splashMinDuration = Duration(milliseconds: 300); | ||
static const String appEmail = '[email protected]'; | ||
|
||
static Uri imagesTipsRepository = | ||
Uri.parse('https://www.github.com/vandadnp/flutter-tips-and-tricks'); | ||
static Uri widgetOfTheWeekLink = Uri.parse( | ||
|
@@ -45,13 +52,7 @@ abstract class Config { | |
Uri.parse('https://www.instagram.com/xmartlabs/?hl=es'); | ||
static Uri xmartlabsTwitter = Uri.parse('https://twitter.com/xmartlabs'); | ||
|
||
static const debugMode = kDebugMode; | ||
|
||
static const firebaseEnabled = !debugMode; | ||
static const analyticsEnabled = !debugMode; | ||
static const crashlyticsEnabled = !debugMode; | ||
|
||
static bool bugseeEnabled = !debugMode && _environment == Environments.dev; | ||
static const databaseName = 'database.db'; | ||
|
||
static const apiBaseUrl = | ||
'https://api.github.com/repos/vandadnp/flutter-tips-and-tricks'; | ||
|
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
40 changes: 40 additions & 0 deletions
40
lib/core/source/providers/shared_preferences_provider.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,40 @@ | ||
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
class LocalSharedPreferencesStorage { | ||
static const String _keyPrefix = 'SharedPreferencesProvider.'; | ||
static const String _alreadyCleanDataKey = '${_keyPrefix}alreadyCleanData'; | ||
|
||
final FlutterSecureStorage _flutterSecureStorage; | ||
|
||
final SharedPreferences _sharedPreferences; | ||
|
||
LocalSharedPreferencesStorage( | ||
this._flutterSecureStorage, | ||
this._sharedPreferences, | ||
); | ||
|
||
Future<LocalSharedPreferencesStorage> init() async { | ||
await _clearSecureStorageOnReinstall(); | ||
return this; | ||
} | ||
|
||
Future<void> _clearSecureStorageOnReinstall() async { | ||
if (!(_sharedPreferences.getBool(_alreadyCleanDataKey) ?? false)) { | ||
await _flutterSecureStorage.deleteAll(); | ||
await _sharedPreferences.setBool(_alreadyCleanDataKey, true); | ||
} | ||
} | ||
|
||
Future<String?> read({required String key}) => | ||
_flutterSecureStorage.read(key: key); | ||
|
||
Future<void> write({required String key, required String? value}) => | ||
_flutterSecureStorage.write(key: key, value: value); | ||
|
||
Future<void> delete({required String key}) => | ||
_flutterSecureStorage.delete(key: key); | ||
|
||
Future<void> containsKey({required String key}) => | ||
_flutterSecureStorage.containsKey(key: key); | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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