getString method

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

Reads and returns the decrypted String stored under key.

Returns defaultValue (default null) if the key does not exist.

Implementation

Future<String?> getString(String key, {String? defaultValue}) async {
  try {
    return await _storage.read(key: key) ?? defaultValue;
  } catch (e, st) {
    throw StorageException(
      message: 'Failed to get String',
      key: key,
      cause: e,
      stackTrace: st,
    );
  }
}