ActionController class

A controller which is used to store and invoke action callbacks. This controller can be used to implement point-to-point communication across widgets. If you want to use publish/subscribe pattern, or said event bus, please use https://pub.dev/packages/event_bus.

Example:

class WidgetA extends StatelessWidget {
  WidgetA({Key? key}) : super(key: key);
  final _action = ActionController()..addAction('key', () { /* do something */ }); // add action

  @override
  Widget build(BuildContext context) => WidgetB(action: _action);
}

class WidgetB extends StatelessWidget {
  const WidgetB({Key? key, required this.action}) : super(key: key);
  final ActionController action;

  @override
  Widget build(BuildContext context) => MaterialButton(onPressed: () => action.invoke('key')); // invoke action
}

Constructors

ActionController()

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

addAction<T>([dynamic key = '', Action<T>? action]) → void
Adds an action.
containsAction([dynamic key = '']) bool
Checks if controller contains the given action key.
dispose() → void
getAction<T>([dynamic key = '']) Action<T>?
Gets the action by the given key, returns null if not found.
invoke<T>([dynamic key = '']) → T?
Invokes an action by the given key, returns null if not found.
invokeWhere(bool where(dynamic)) List
Invokes some actions by the given where key condition, and returns the list of returned results.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeAction<T>([dynamic key = '']) → void
Removes an action.
toString() String
A string representation of this object.
inherited

Operators

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