addObject method
Adds an object to the current opened box
addedObject
: A Map<String, dynamic> representing the new object to be added.
Returns a Future
Implementation
Future<bool> addObject(Map<String, dynamic> addedObject) async {
final currentBox = _hiveViewState.currentOpenedBox!;
try {
final fromJson = _hiveViewState.boxesMap[currentBox]!;
final newAddedObject = fromJson(addedObject);
await currentBox.put(addedObject["id"], newAddedObject);
return true;
} catch (e) {
_errorCallback(e.toString());
return false;
}
}