BlocEventChannel class

BlocEventChannel represents a node in a tree of event channels, mirroring the widget tree to an extent. The tree is only connected upwards (child knows its parent).

BlocEventListeners can be added to each BlocEventChannel. These will listen to events fired directly to the event channel. By default, these events will also be propagated up the tree, effectively refiring the event to each parent.

BlocProvider and RepositoryProvider will both automatically Provide the event channel down the widget tree.

While the event channel system might mirror the widget tree, it doesn't need to be used alongside it. This lets you use the BlocEventChannel in non-Widget environments.

Implemented types

Constructors

BlocEventChannel([BlocEventChannel? _parentChannel])
_parentChannel is the parent of this channel. This can only be set in the constructor to ensure that the BlocEventChannel tree does in fact remain a tree with no cycles.

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

addEventListener(String eventType, BlocEventListener listener) → void
Adds a listener for the specific eventType. Multiple listeners can be added for each eventType
dispose() → void
override
fireEvent(String eventType, dynamic payload) → void
Fires and event that is sent up the event channel, stopping only when it reaches the top or an event stops the propagation.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeEventListener(String eventType, BlocEventListener listener) → void
Removes the given listener from the given eventType. Will do nothing if listener doesn't exist.
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

simpleListener(dynamic listener(dynamic), {dynamic stopPropagation = false}) BlocEventListener
Helper function to simplify making a BlocEventListener by calling listener and then returning stopPropagation