Producer<T> constructor

Producer<T>({
  1. T? initialValue,
  2. String? name,
})

Creates a new Producer.

Implementation

Producer({T? initialValue, String? name})
    : _name = name,
      _observers = [] {
  // we don't want to set an initial value for derived, even
  // if the type is nullable.
  final isNullableAndNotDerived = _isNullable && !_isDerived;

  if (initialValue != null || isNullableAndNotDerived) {
    _initialValue = initialValue as T;
    _value = initialValue;
    _isEmpty = false;
  }
}