JSONBridge class
If it (data) can be a value in a Map<String, dynamic>
you can save it into a json file with JSONBridge.
JSONBridge is a simple wrapper around a JSON file
It allows you to store and retrieve data from a JSON file.
The JSON file is stored in the application document directory.
But you can also specify a directory and a file name when calling the init method.
JSONBridge is a singleton
JSONBridge support manipulating nested keys with dot separated.
Use JSONBridge to store user preferences, settings, data, etc.
Use JSONBridge to build the next big and powerfull noSQL database for dart and flutter apps.
Use JSONBridge to store any data in a JSON file within your application.
Use JSONBridge to check if user is using your app for the first time.
Use JSONBridge to track user activity and show him the last seen screen when he restart the app.
Usecases are endless, use your imagination.
Constructors
- JSONBridge()
-
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clear(
) → void - Deletes the JSON file.
-
delete(
String key) → void - Delete a key from the JSON file.
-
get(
String key) → dynamic - Get a value from the JSON file.
-
has(
String key) → bool - Check if a key exists in the JSON file.
-
init(
{required String fileName, String? dir}) → void - Creates a JSON file in the application document directory or in the one provided.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
read(
) → Map< String, dynamic> - Reads the JSON file and returns a Map. If the file is empty, an empty Map is returned.
-
set(
String key, dynamic value) → void - Add or update a key with it value to the JSON file.
-
toString(
) → String -
A string representation of this object.
inherited
-
write(
Map< String, dynamic> data) → void - Writes a Map to the JSON file.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited