onSetValue method

  1. @override
Future<void> onSetValue(
  1. String k,
  2. T value
)
override

Asynchronously sets the value for the given key in the nested storage map, creating intermediate maps if needed.

Uses dot notation for nested paths. Automatically initializes missing sub-maps with empty Map<String, dynamic> using ??= for null safety. No return value. Called by setValue to update the underlying storage and emit changes via the subject.

Implementation

@override
Future<void> onSetValue(String k, T value) async {
  List<String> parts = k.split('.');
  Map<String, dynamic> current = storage;
  for (int i = 0; i < parts.length; i++) {
    String part = parts[i];
    if (i == parts.length - 1) {
      current[part] = value;
    } else {
      current[part] ??= <String, dynamic>{};
      current = current[part] as Map<String, dynamic>;
    }
  }
}