initState method

void initState()

Implementation

void initState() {
  widget.initState?.call(this);

  var isRegistered = Get.isRegistered<T>(tag: widget.tag);

  if (widget.global) {
    if (isRegistered) {
      if (Get.isPrepared<T>(tag: widget.tag)) {
        _isCreator = true;
      } else {
        _isCreator = false;
      }

      _controllerBuilder = () => Get.find<T>(tag: widget.tag);
    } else {
      _controllerBuilder =
          () => (widget.create?.call(this) ?? widget.init?.call());
      _isCreator = true;
      if (widget.lazy) {
        Get.lazyPut<T>(_controllerBuilder!, tag: widget.tag);
      } else {
        Get.put<T>(_controllerBuilder!(), tag: widget.tag);
      }
    }
  } else {
    if (widget.create != null) {
      _controllerBuilder = () => widget.create!.call(this);
      Get.spawn<T>(_controllerBuilder!, tag: widget.tag, permanent: false);
    } else {
      _controllerBuilder = widget.init;
    }
    _controllerBuilder =
        (widget.create != null ? () => widget.create!.call(this) : null) ??
            widget.init;
    _isCreator = true;
    _needStart = true;
  }
}