getBool method

Future<bool?> getBool(
  1. String key, {
  2. bool? defaultValue,
})

Returns the stored bool, or defaultValue if the key does not exist.

Implementation

Future<bool?> getBool(String key, {bool? defaultValue}) async {
  try {
    final raw = await _storage.read(key: key);
    if (raw == null) return defaultValue;
    return raw == 'true';
  } catch (e, st) {
    throw StorageException(
      message: 'Failed to get bool',
      key: key,
      cause: e,
      stackTrace: st,
    );
  }
}