firstOrNull property

Future<MapEntry<TKey, TVal>?> firstOrNull

Gets the first (key,value) stored in the box

Implementation

Future<MapEntry<TKey, TVal>?> get firstOrNull async {
  var firstOrDefaultKey = dataBox.keys.isEmpty ? null : dataBox.keys.first;
  if (firstOrDefaultKey == null) return null;
  final val = await dataBox.get(firstOrDefaultKey);
  if (val == null) return null;
  return MapEntry(firstOrDefaultKey, val);
}