operator []= method

void operator []=(
  1. String key,
  2. Object? value
)

Implementation

void operator []=(String key, Object? value) {
  if (value == null && !_map.containsKey(key)) return;
  if (_map[key] == value) return;

  if (value == null) {
    _map.remove(key);
  } else {
    _map[key] = value;
  }

  try {
    _file.writeAsStringSync('${_jsonEncoder.convert(_map)}\n');
  } catch (_) {}
}