putValue<T> method

void putValue<T>({
  1. required T? value,
  2. String? token,
})

Puts a value in the specified GadgetSubject stored in the map.

If no GadgetSubject is associated to the key generated using the toValueKey function, a new one is automatically created.

The provided value can be null.

Implementation

void putValue<T>({required T? value, String? token}) {
  // ignore: close_sinks
  GadgetSubject<T?>? subject =
      _subjectMap[toValueKey(T, token: token)] as GadgetSubject<T?>?;
  if (subject == null) {
    subject = _createSubject<T>();
    _subjectMap[toValueKey(T, token: token)] = subject;
  }
  subject.add(value);
}