getDataOnce method

Future<DataSnapshot?> getDataOnce(
  1. String path
)

Implementation

Future<DataSnapshot?> getDataOnce(String path) async {
  try {
    final snapshot = await _dbRef.child(path).get();
    if (snapshot.exists) {
      print('Data retrieved from $path: ${snapshot.value}');
    } else {
      print('No data available at $path');
    }
    return snapshot;
  } catch (e) {
    print('Error getting data: $e');
    return null;
  }
}