CurrentComponent<T extends CurrentViewModel> class
abstract
Base class for any component that needs to be updated when the state of your component changes.
Requires a class that extends CurrentViewModel to be passed to the viewModel argument. The
CurrentViewModel is responsible for notifying this component when the UI needs to be updated.
By default, CurrentComponent also owns the lifecycle of the provided viewModel and disposes it
when the accompanying CurrentState is disposed. Set disposeViewModel to false when using
an externally managed or shared CurrentViewModel instance.
Usage
class MyComponent extends CurrentComponent<MyViewModel> {
const MyComponent({super.key, required super.viewModel});
@override
CurrentState<CurrentComponent<CurrentViewModel>, MyViewModel> createCurrent() => _MyComponentState(viewModel);
}
Constructors
- CurrentComponent({Key? key, required T viewModel, bool debugPrintStateChanges = false, bool disposeViewModel = true})
-
const
Properties
- debugPrintStateChanges → bool
-
final
- disposeViewModel → bool
-
Whether this component owns the lifecycle of the provided viewModel.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one component replaces another component in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- viewModel → T
-
final
Methods
-
createCurrent(
) → CurrentState< CurrentComponent< CurrentViewModel> , T> - Create an instance of CurrentState for this component.
-
createElement(
) → Element -
Creates a
StatefulElementto manage this component's location in the tree.inherited -
createState(
) → State< StatefulComponent> - Avoid overriding this function. createCurrent handles the creation of the component state. Overriding this function can have unintended side affects. You've been warned.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited