GetxController<T extends GetxState> class abstract

A base controller class that provides state management functionality.

Extend this class to create a controller that can be used with GetX's state management system. This class provides methods to update the UI when the controller's state changes.

The state class must extend GetxState and implement GetxState.onClose to properly dispose of RxVariables when the controller is disposed.


Example:

class _CounterState extends GetxState {
  final _count = 0.obs;

  int get count => _count.value;

  @override
  void onClose() {
    _count.close();
  }
}

class CounterController extends GetxController<_CounterState> {
  @override
  final state = _CounterState();

  void increment() {
    state._count.value++;
    update();
  }
}
Inheritance
Mixed-in types
Implementers

Constructors

GetxController()

Properties

hashCode int
The hash code for this object.
no setterinherited
initialized bool
Checks whether the controller has already been initialized.
no setterinherited
isClosed bool
Checks whether the controller has already been closed.
no setterinherited
isDisposed bool
Whether this notifier has been disposed.
no setterinherited
listenersLength int
The current number of registered listeners.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state → T
The state object managed by this controller.
no setter

Methods

addListener(GetStateUpdate listener) → Disposer
Registers a listener and returns a Disposer to unregister it.
inherited
addListenerId(Object? key, GetStateUpdate listener) → Disposer
Adds a listener to the group identified by key.
inherited
containsId(Object id) bool
Returns true if a listener group with the given id exists.
inherited
containsListener(GetStateUpdate listener) bool
Returns true if listener is currently registered.
inherited
dispose() → void
Disposes all listener groups and marks this mixin as disposed.
inherited
disposeId(Object id) → void
To dispose an id from future updates(), this ids are registered by GetBuilder() or similar, so is a way to unlink the state change with the Widget from the Controller.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyGroupChildrens(Object id) → void
Reports a read to the Notifier system for the group identified by id.
inherited
onClose() → void
Called when the controller is disposed.
override
onDelete() → void
Called when the controller is removed from memory.\n ///\n /// Calls onClose and marks the controller as closed. Subsequent calls are ignored.
inherited
onInit() → void
Called immediately after the widget is allocated in memory. You might use this to initialize something for the controller.
inherited
onReady() → void
Called 1 frame after onInit(). It is the perfect place to enter navigation events, like snackbar, dialogs, or a new route, or async request.
inherited
onStart() → void
Called at the exact moment the widget is allocated in memory. It uses an internal "callable" type, to avoid any @overrides in subclasses. This method should be internal and is required to define the lifetime cycle of the subclass.
inherited
refresh() → void
Notifies all registered listeners to trigger a rebuild.
inherited
refreshGroup(Object id) → void
Notifies all listeners in the group identified by id.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that the object notifies.
inherited
removeListenerId(Object id, VoidCallback listener) → void
Removes a listener from the group identified by id.
inherited
reportAdd(VoidCallback disposer) → void
Reports a disposer callback to the Notifier system for cleanup.
inherited
reportRead() → void
Reports a read access to the Notifier system so reactive widgets can track dependencies.
inherited
toString() String
A string representation of this object.
inherited
update([List<Object>? ids, bool condition = true]) → void
Notifies listeners to update the UI.

Operators

operator ==(Object other) bool
The equality operator.
inherited