mount<T> method

T? mount<T>({
  1. dynamic key,
  2. T init()?,
  3. bool stateNotifier = false,
})

Returns value by given key and Type from this Widget's internal arg store. If object is not found, then widget will init and store it to args. Object is also registered for dispose.

Internally uses ControlArgs. Check ControlArgs.getWithFactory. Use holder.argStore to get raw access to ControlArgs.

Implementation

T? mount<T>({dynamic key, T Function()? init, bool stateNotifier = false}) {
  final value =
      holder.argStore.getWithFactory<T>(key: key, defaultValue: init);

  if (value is Disposable) {
    if (stateNotifier) {
      registerStateNotifier(value);
    } else {
      register(value);
    }
  }

  return value;
}