onGetValue method

  1. @override
Future<T> onGetValue(
  1. String k
)
override

Implementation

@override
Future<T> onGetValue(String k) async {
  final List<String> parts = k.split('.');
  Map<String, dynamic> current = storage;
  for (int i = 0; i < parts.length; i++) {
    final String part = parts[i];

    if (i == parts.length - 1) {
      if (current.containsKey(part)) {
        return current[part] as T;
      } else {
        throw Exception("Key not found: $k");
      }
    } else {
      if (current[part] is Map<String, dynamic>) {
        current = current[part] as Map<String, dynamic>;
      } else {
        throw Exception("Key not found: $k");
      }
    }
  }

  throw Exception("Key not found: $k");
}