VN<T> constructor

VN<T>(
  1. T initialValue, [
  2. ChangeType changeType = ChangeType.smart
])

Creates a VN instance with an initial value and optional change behavior.

  • initialValue: The initial value of this VN.
  • changeType: Determines the behavior of updates. Defaults to ChangeType.smart.

If kFlutterMemoryAllocationsEnabled is enabled, the instance is tracked.

Implementation

VN(T initialValue, [this.changeType = ChangeType.smart])
    : _value = initialValue {
  _valueSetter = switch (changeType) {
    ChangeType.hard => hardSet,
    ChangeType.silent => silentSet,
    ChangeType.smart => smartSet,
  };
  if (kFlutterMemoryAllocationsEnabled) {
    ChangeNotifier.maybeDispatchObjectCreation(this);
  }
}