putIfAbsent method

dynamic putIfAbsent(
  1. dynamic key,
  2. Data ifAbsent, {
  3. bool notify = true,
})

Implementation

dynamic putIfAbsent(dynamic key, Data ifAbsent, {bool notify = true}) {
  if (_value is! Map) throw Exception('Cannot insert into not a map');
  final res = (_value as Map).putIfAbsent(key, () {
    ifAbsent.addParent(this);
    return ifAbsent;
  });
  if (notify) notifyListeners();
  return res;
}