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 via AgentProvider.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 to state 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 and StateAgentBuilder 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 a state change such as navigation, showing a SnackBar, showing a Dialog, etc... The listener is guaranteed to only be called once for each state change unlike the builder in StateAgentBuilder.
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 the BuildContext 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 previous state and the current state and is responsible for returning a bool which determines whether to rebuild StateAgentBuilder with the current state.
StateAgentListenerCondition<S> = bool Function(S previous, S current)
Signature for the listenWhen function which takes the previous state and the current state and is responsible for returning a bool which determines whether or not to call StateAgentWidgetListener of StateAgentListener with the current state.
StateAgentWidgetBuilder<S> = Widget Function(BuildContext context, S state)
Signature for the builder function which takes the BuildContext and state and is responsible for returning a widget which is to be rendered. This is analogous to the builder function in StreamBuilder.
StateAgentWidgetListener<S> = void Function(BuildContext context, S state)
Signature for the listener function which takes the BuildContext along with the state and is responsible for executing in response to state changes.