getInt method

Future<int?> getInt(
  1. String key
)

Implementation

Future<int?> getInt(String key) async {
  debugPrint('PATH : ${path}/${key}');

  try {
    DataSnapshot snapshot = await _database.child(path).child(key).get();
    if (snapshot.value != null) {
      return int.tryParse('${snapshot.value}');
    } else {
      return null; // Return null if the key doesn't exist or has no value
    }
  } catch (e) {
    print('Error fetching data: $e');
    return null; // Return null in case of any error
  }
}