editeDataItem method
Edits a data item in Firebase.
If _data is null, returns an error result.
If _file is not null, uploads the file and updates the data in Firestore.
Otherwise, updates the data directly in Firestore.
Returns a Result indicating success or an error.
Implementation
@override
Future<Result<RemoteBaseModel, RemoteBaseModel>> editeDataItem(
String id) async {
try {
if (_data == null) {
return Result.error(RemoteBaseModel(message: "data is null"));
}
if (_file == null) {
await _fireStoreAction.editDataCloudFirestore(
path: _path, id: id, mymap: _data!.toJson());
} else {
await _fireStoreAction.editeDataCloudFirestorWithUploadAndReplacement(
path: _path,
id: id,
mymap: _data!.toJson(),
file: _file,
oldurl: deleteUrl,
imageField: imageField!);
}
return Result.data(RemoteBaseModel(data: "done"));
} on Exception catch (e) {
return Result.error(RemoteBaseModel(message: e.toString()));
}
}