setJson method

void setJson(
  1. String key,
  2. Object? value
)

Sets a JSON flag.

value must be JSON-encodable: null, a number, string, or bool, or lists and string-keyed maps of those. Throws an ArgumentError otherwise, and a StateError after shutdown

Implementation

void setJson(String key, Object? value) {
  final String encoded;
  try {
    encoded = jsonEncode(value);
  } catch (_) {
    throw ArgumentError.value(value, 'value', 'must be JSON encodable');
  }
  _backend.set(key, StoredJson(encoded));
}