Fixed and removed the example example_flutter_secure_storage_provider.dart

This commit is contained in:
Sambo Chea 2021-05-14 17:05:16 +07:00
parent 5f282e4b59
commit 0cf5803ac5
3 changed files with 5 additions and 92 deletions

View File

@ -27,4 +27,7 @@
## 1.0.6 ## 1.0.6
- Add async function support - Add async function support
- Add functions for set and remove for system config and file functions - Add functions for set and remove for system config and file functions
- Add TextFormatter for format the string with args - Add TextFormatter for format the string with args
## 1.0.7
- Removed example "example_flutter_secure_storage_provider.dart"

View File

@ -1,90 +0,0 @@
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:configurable/mutable_configurable_provider.dart';
class LocalStorageProvider
extends MutableConfigurationProvider {
static FlutterSecureStorage _storage;
FlutterSecureStorage _getStorage() {
if (_storage == null) {
_storage = new FlutterSecureStorage();
}
return _storage;
}
@override
bool containsKey(String key) {
var _hasKey = false;
_getStorage().containsKey(key: key).then((value) => _hasKey = value);
return _hasKey;
}
@override
Future<bool> containsKeyAsync(String key) async {
return await _getStorage().containsKey(key: key);
}
@override
String? getOrNull(String key, {String defaultValue}) {
String _value;
_getStorage().read(key: key).then((value) => {
_value = value
});
if (_value == null && defaultValue != null) {
return defaultValue;
} else {
return _value;
}
}
@override
Future<String?> getOrNullAsync(String key, {String defaultValue}) async {
String _value = await _getStorage().read(key: key);
if (_value == null && defaultValue != null) {
return defaultValue;
} else {
return _value;
}
}
@override
void remove(String key) {
_getStorage().delete(key: key);
}
@override
Future<void> removeAsync(String key) async {
await _getStorage().delete(key: key);
}
@override
void removeAll() {
_getStorage().deleteAll();
}
@override
Future<void> removeAllAsync() async {
await _getStorage().deleteAll();
}
@override
void set(String key, String value) {
_getStorage().write(key: key, value: value);
}
@override
Future<void> setAsync(String key, String value) async {
await _getStorage().write(key: key, value: value);
}
@override
Future<void> setAllAsync(Map<String, String> configs) async {
configs.entries.forEach((element) {
setAsync(element.key, element.value);
});
}
}

View File

@ -1,6 +1,6 @@
name: configurable name: configurable
description: System Configuration and Dotenv Environment for Dart and Flutter description: System Configuration and Dotenv Environment for Dart and Flutter
version: 1.0.6 version: 1.0.7
homepage: https://github.com/CUBETIQ/system-config-dart homepage: https://github.com/CUBETIQ/system-config-dart
repository: https://github.com/CUBETIQ/system-config-dart.git repository: https://github.com/CUBETIQ/system-config-dart.git