initState method
void
initState()
Implementation
void initState() {
widget.initState?.call(this);
final bool 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()) as T;
_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) as T;
Get.spawn<T>(_controllerBuilder!, tag: widget.tag, permanent: false);
} else {
_controllerBuilder = widget.init;
}
_controllerBuilder = (widget.create != null
? () => widget.create!.call(this) as T
: null) ??
widget.init;
_isCreator = true;
_needStart = true;
}
}