putIfAbsent method

  1. @override
void putIfAbsent(
  1. dynamic key,
  2. dynamic ifAbsent()
)
override

If isImmutable is false, or the key already exists, then allow the edit. Throw JsonObjectLiteException if we're not allowed to add a new key

Implementation

@override
void putIfAbsent(dynamic key, Function() ifAbsent) {
  if (isImmutable == false || containsKey(key)) {
    _objectData.putIfAbsent(key, ifAbsent);
  } else {
    throw const JsonObjectLiteException('JsonObject is not extendable');
  }
}