getData method

Future<Object?> getData(
  1. String nodePath
)

Retrieves data from a specified node path in the database.

The nodePath specifies the path within the database from which data is to be fetched. Returns the data as an Object if the path exists and has data; otherwise, returns null.

Implementation

Future<Object?> getData(String nodePath) async {
  Object? _val = {};
  await database.ref(nodePath).once().then((event) {
    var data = event.snapshot.value;
    _val = data;
  });
  return _val;
}