XControllable<TEvent> class
Annotation for XController classes.
Put this annotation above your controllers so the generator can do its job.
What is this?
TEvent
is the event type where you specify method events for your controller.
It is optional, if TEvent
will not be specified, then nothing will be generated.
Example
Create your event like so:
abstract class MyEvent {
void nameChanged(String newName);
void somethingElseHappened(DataClass data);
}
Annotate your controller:
@XControllable<MyEvent>
class MyController extends XController<MyState, MyEffect> {
...
}
And run the build runner.
Now, on the UI level, you can raise these events this way:
context.myController.raiseEvent.nameChanged('Some name');
context.myController.raiseEvent.somethingElseHappened('Some name');
Remember❗️
Until you override these events in your controller, they will throw an UnimplementedError when called. To override them, do the following:
@XControllable<MyEvent>
class MyController extends XController<MyState, MyEffect> {
...
@override
void onNameChanged(String newName) { // note: it is not nameChanged, but onNameChanged
emitWith(name: newName); // or whatever
}
@override
void onSomethingElseHappened(DataClass data) {
/* Do something with this ... */
}
}
- Annotations
-
- @Target({TargetKind.classType})
Constructors
- XControllable()
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
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