NanoController<ViewState extends NanoViewState> class abstract

An abstract controller managing state NanoState for Flutter UI components.

Extends ChangeNotifier and implements NanoStateObservable to notify listeners when state changes. Requires ViewState to extend NanoViewState for structured, immutable state models.

Inheritance
Implemented types
Implementers

Constructors

NanoController({required ViewState initialState})
Creates a new NanoController instance with a required initialState.

Properties

hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether any listeners are currently registered.
no setterinherited
hasUnsavedChanges → bool
Whether this controller currently holds unsaved changes.
no setter
isDisposed → bool
Whether the controller has been disposed.
no setter
Observable stream of one-shot reactive navigation events.
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
state ↔ NanoState<ViewState>
The current state of the controller.
getter/setter pairoverride-getter
viewState → ViewState
Retrieves the current ViewState data from state.
no setter

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
dispose() → void
Discards any resources used by the object.
override
emit(NanoState<ViewState> newState) → void
Emits a new state and notifies all registered listeners.
emitCustom<Payload>(Payload payload, {ViewState? data}) → void
Emits a CustomState with the provided payload and optional data.
emitError({NanoMessageKey? key, ViewState? data}) → void
Emits an ErrorState with optional key and data.
emitInitial({ViewState? data}) → void
Emits an InitialState with optional data.
emitLoaded(ViewState data) → void
Emits a LoadedState with the provided data.
emitLoading({ViewState? data}) → void
Emits a LoadingState with optional data.
emitNavigation(String routeName, {NanoNavigationMode mode = NanoNavigationMode.push, Object? args}) → void
Emits a one-shot navigation event to be handled by NanoScaffold.
emitSuccess({NanoMessageKey? key, ViewState? data}) → void
Emits a SuccessState with optional key and data.
emitWarning({NanoMessageKey? key, ViewState? data}) → void
Emits a WarningState with optional key and data.
execute<T>(Future<T> action(), {bool emitLoadingOnRequest = true, void onSuccess(T result)?, void onError(Object error)?}) → Future<void>
Executes an asynchronous action.
init(String? id) → Future<void>
Initializer method called when controller is instantiated or bound to a view.
nanoCommand0<Output>(Future<Output> action(), {void onSuccess(Output result)?, void onError(Object error)?, bool emitLoadingOnRequest = true}) → NanoCommand0<Output>
Creates and registers a parameterless NanoCommand0 with automatic disposal.
nanoCommand1<Argument, Output>(Future<Output> action(Argument arg), {void onSuccess(Output result)?, void onError(Object error)?, bool emitLoadingOnRequest = true}) → NanoCommand1<Argument, Output>
Creates and registers a single-argument NanoCommand1 with automatic disposal.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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