-
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.
Updated: made message nullable Updated: response class Updated: readability Added: local storage extendable class Updated: return type Updated: flow of parameter passing
- Loading branch information
1 parent
259ad86
commit 196c193
Showing
6 changed files
with
207 additions
and
61 deletions.
There are no files selected for viewing
114 changes: 114 additions & 0 deletions
114
lib/vaahextendflutter/services/storage/local/extendable.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,114 @@ | ||
import '../storage_response.dart'; | ||
import 'storage.dart'; | ||
|
||
/// [LocalStorageExtendable] can be extended to have more class features other than the available | ||
/// features. | ||
/// | ||
/// Example: | ||
/// | ||
/// ```dart | ||
/// class ELS extends LocalStorageExtendable { | ||
/// void myFunction(){ | ||
/// // logic | ||
/// } | ||
/// } | ||
/// | ||
/// final ELS els = ELS(); | ||
/// | ||
/// void useCase(){ | ||
/// final response = await els.create( | ||
/// collectionName: 'posts', | ||
/// key: 'key', | ||
/// value: 'value', | ||
/// ); // existing method | ||
/// | ||
/// final newResponse = await els.myFuction(); // added method | ||
/// } | ||
/// | ||
/// ``` | ||
class LocalStorageExtendable { | ||
static const String defaultCollectionName = 'vaah-fluter-box'; | ||
|
||
StorageResponse add(String collectionName) { | ||
return LocalStorage.add(collectionName); | ||
} | ||
|
||
Future<StorageResponse> create({ | ||
String collectionName = defaultCollectionName, | ||
required String key, | ||
required String value, | ||
}) { | ||
return LocalStorage.create(key: key, value: value); | ||
} | ||
|
||
Future<StorageResponse> createMany({ | ||
String collectionName = defaultCollectionName, | ||
required Map<String, String> values, | ||
}) { | ||
return LocalStorage.createMany(values: values); | ||
} | ||
|
||
Future<StorageResponse> read({ | ||
String collectionName = defaultCollectionName, | ||
required String key, | ||
}) { | ||
return LocalStorage.read(collectionName: collectionName, key: key); | ||
} | ||
|
||
Future<StorageResponse> readMany({ | ||
String collectionName = defaultCollectionName, | ||
required List<String> keys, | ||
}) { | ||
return LocalStorage.readMany(keys: keys); | ||
} | ||
|
||
Future<StorageResponse> readAll({String collectionName = defaultCollectionName}) { | ||
return LocalStorage.readAll(collectionName: collectionName); | ||
} | ||
|
||
Future<StorageResponse> update({ | ||
String collectionName = defaultCollectionName, | ||
required String key, | ||
required String value, | ||
}) { | ||
return LocalStorage.update(key: key, value: value); | ||
} | ||
|
||
Future<StorageResponse> updateMany({ | ||
String collectionName = defaultCollectionName, | ||
required Map<String, String> values, | ||
}) { | ||
return LocalStorage.updateMany(values: values); | ||
} | ||
|
||
Future<StorageResponse> createOrUpdate({ | ||
String collectionName = defaultCollectionName, | ||
required String key, | ||
required String value, | ||
}) { | ||
return LocalStorage.createOrUpdate(key: key, value: value); | ||
} | ||
|
||
Future<StorageResponse> createOrUpdateMany({ | ||
String collectionName = defaultCollectionName, | ||
required Map<String, String> values, | ||
}) { | ||
return LocalStorage.createOrUpdateMany(values: values); | ||
} | ||
|
||
Future<StorageResponse> delete( | ||
{String collectionName = defaultCollectionName, required String key}) { | ||
return LocalStorage.delete(collectionName: collectionName, key: key); | ||
} | ||
|
||
Future<StorageResponse> deleteMany({ | ||
String collectionName = defaultCollectionName, | ||
List<String> keys = const [], | ||
}) { | ||
return LocalStorage.deleteMany(keys: keys); | ||
} | ||
|
||
Future<StorageResponse> deleteAll({String collectionName = defaultCollectionName}) { | ||
return LocalStorage.deleteAll(collectionName: collectionName); | ||
} | ||
} |
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
Oops, something went wrong.