agent_flutter library
Support for doing something awesome.
More dartdocs go here.
Classes
-
Agent<
Event extends AgentBaseEvent> - AgentBaseEvent
-
AgentConnected<
BaseAgentA, BaseAgentB> -
AgentConnector<
A extends Agent< AgentBaseEvent> > -
AgentConsumer<
A extends Agent< AgentBaseEvent> > -
AgentDisconnected<
BaseAgentA, BaseAgentB> - AgentEvent
-
AgentListener<
A extends Agent< AgentBaseEvent> > -
AgentProvider<
T extends BaseAgent< AgentBaseEvent> > -
Takes a
Create
function that is responsible for creating the Agent or StateAgent and a child which will have access to the instance viaAgentProvider.of(context)
. It is used as a dependency injection (DI) widget so that a single instance of a Agent or StateAgent can be provided to multiple widgets within a subtree. - MultiAgentProvider
- Merges multiple AgentProvider widgets into one widget tree.
-
StateAgent<
State, Event extends AgentBaseEvent> -
StateAgentBuilder<
A extends Stateful< S> , S> -
StateAgentBuilder handles building a widget in response to new
states
. StateAgentBuilder is analogous to StreamBuilder but has simplified API to reduce the amount of boilerplate code needed as well as agent-specific performance improvements. Please refer to StateAgentListener if you want to "do" anything in response tostate
changes such as navigation, showing a dialog, etc... -
StateAgentBuilderBase<
B extends Stateful< S> , S> - Base class for widgets that build themselves based on interaction with a specified agent.
-
StateAgentConsumer<
A extends Stateful< S> , S> -
StateAgentConsumer exposes a builder and listener in order react to new
states.
StateAgentConsumer is analogous to a nested
StateAgentListener
andStateAgentBuilder
but reduces the amount of boilerplate needed. StateAgentConsumer should only be used when it is necessary to both rebuild UI and execute other reactions to state changes in the agent. -
StateAgentListener<
A extends Stateful< S> , S> -
Takes a StateAgentWidgetListener and an optional agent and invokes
the listener in response to
state
changes in the agent. It should be used for functionality that needs to occur only in response to astate
change such as navigation, showing aSnackBar
, showing aDialog
, etc... The listener is guaranteed to only be called once for eachstate
change unlike thebuilder
inStateAgentBuilder
. -
StateAgentListenerBase<
A extends Stateful< S> , S> - Base class for widgets that listen to state changes in a specified agent.
Mixins
- AgentProviderSingleChildWidget
-
Mixin which allows
MultiAgentProvider
to infer the types of multiple AgentProviders. - StateAgentListenerSingleChildWidget
-
Mixin which allows
MultiAgentListener
to infer the types of multiple StateAgentListeners.
Typedefs
-
AgentWidgetBuilder<
A> = Widget Function(BuildContext context, A agent) -
Signature for the
builder
function which takes theBuildContext
and and is responsible for returning a widget which is to be rendered. -
AgentWidgetListener<
E extends AgentBaseEvent> = void Function(BuildContext context, E event) -
CreateAgent<
A extends Agent< AgentBaseEvent> > = A Function(BuildContext context) -
StateAgentBuilderCondition<
S> = bool Function(S previous, S current) -
Signature for the
buildWhen
function which takes the previousstate
and the currentstate
and is responsible for returning a bool which determines whether to rebuild StateAgentBuilder with the currentstate
. -
StateAgentListenerCondition<
S> = bool Function(S previous, S current) -
Signature for the
listenWhen
function which takes the previousstate
and the currentstate
and is responsible for returning a bool which determines whether or not to call StateAgentWidgetListener of StateAgentListener with the currentstate
. -
StateAgentWidgetBuilder<
S> = Widget Function(BuildContext context, S state) -
Signature for the
builder
function which takes theBuildContext
andstate
and is responsible for returning a widget which is to be rendered. This is analogous to thebuilder
function in StreamBuilder. -
StateAgentWidgetListener<
S> = void Function(BuildContext context, S state) -
Signature for the
listener
function which takes theBuildContext
along with thestate
and is responsible for executing in response tostate
changes.