EmitterContainer<C extends ContainerChange> class

A ChangeEmitter that can be subclassed in order to compose multiple ChangeEmitters into a single unit. To use, simply define any ChangeEmitters you need in your class and override the children getter with a complete list of all of them. This will dispose all children when the container is disposed and will trigger the container to emit a change whenever any of the children changes

If you want only a subset of the container's children to emit changes, override the emittingChildren getter:

class TextStyleState extends EmitterContainer {
 final bold = ValueEmitter(false);
 final italic = ValueEmitter(false);
 final color = ValueEmitter<Color>(Colors.red);
 ValueEmitter<bool> boldAndRed;

  TextStyleState(){
    boldAndRed = ValueEmitter.reactive(
      [bold, color],
      () => bold.value && color.value == Colors.red
    );
  }

 @override
 get children => [bold, italic, color, isRedAndBold];

 @override
 get emittingChildren => [text, bold, italic, color];
}
Inheritance
Implemented types
Implementers

Constructors

EmitterContainer({bool emitDetailedChanges = false})

Properties

changes Stream<C>
The stream of Changes to notify your UI or other state elements that they should update.
read-only, override
children List<ChangeEmitter<Change>>
Override to provide a list of all the ChangeEmitters defined in your subclass. This will dispose all children when this class is disposed and will emit a ContainerChange whenever any of the children change so that UI or other elements of your state can update reactively. If you only want a subset of the children to trigger changes, override emittingChildren.
read-only
emitDetailedChanges bool
Whether to emit changes that include detailed information about the specific change. Defaults to false which will emit the same cached change object to minimize garbage collection. [...]
final
emittingChildren List<ChangeEmitter<Change>>
A list of children that should trigger this container to emit changes. If you want all children to trigger changes, then you don't need to override this getter.
read-only
hashCode int
The hash code for this object. [...]
read-only, inherited
isDisposed bool
Whether this has been disposed.
read-only, inherited
parent ChangeEmitter<Change>
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

addChangeToStream(C change) → void
Used by subclasses to broadcast Changes.
@protected, inherited
controllerChangeFromChildChange(ChangeEmitter<Change> child, Change childChange) → C
override this method in order to create and use your own subclass of ContainerChange
dispose() → void
Disposes resources of all children and this.
@mustCallSuper, override
emit({bool quiet = false}) → void
Emits new ContainerChange.any). [...]
findAncestorOfExactType<T extends ChangeEmitter<Change>>() → T
@protected, inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
registerChildren() → void
override
toString() String
A string representation of this object. [...]
inherited

Operators

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