read method
Reads data from the specified path.
The path
parameter identifies the location of the data to read.
Returns a Future that completes with the data of type D
if available,
or null
if no data exists at the specified path.
If the read operation fails, the future will complete with an error.
Implementation
@override
Future<Map<String, dynamic>?> read(String path) async {
final snapshot = await datasource.ref(path).get();
final value = snapshot.value;
if (value == null) return null;
if (value is Map<Object?, Object?>) {
return value.map(
(key, val) => MapEntry(key.toString(), val),
);
}
return null;
}