Flow class abstract Features Architecture Walkthroughs Demo · ICU Alarm Pipeline Demo · Pharmacy Transactions Demo · Search Stability Demo · Forensic Pipeline HowTo-FlowInstructions Method Chaining (Fluent)
The Transcription Orchestrator for the Cell framework, responsible for converting (transcribing) external stimuli, persistent state, and logic into reactive Cell topographies.
Flow acts as the Administrative Facade over the Mitosis reactive layer. It provides a declarative, static API for building complex reactive pipelines without manually instantiating FlowInstruction or Receptor objects.
When to use
Use Flow as your primary entry point for reactive orchestration:
- Pipeline Creation: Bridging external Futures or Streams into cells.
- Synchronous Logic: Applying filters, maps, and scans.
- Asynchronous Coordination: Managing concurrency with
switchMap,mergeMap, andasyncMap. - Temporal Control: Implementing
debounce,throttle, anddelaylogic. - Topological Routing: Branching or partitioning signals through the graph.
How it works
- Every static method in Flow acts as a factory for a specific FlowInstruction.
- When called, the method creates the instruction, binds it to the provided
sourcecell, and materializes a FlowHandle. - The FlowHandle provides access to the output
.celland an.emit()mechanism, while managing the underlying receptor lifecycle. - Transformations are optimized into flyweight receptors that execute within the host cell's switching fabric.
See Also:
- FlowInstruction: The stateless blueprint for reactive logic.
- FlowHandle: The live instance of a flow pipeline.
- Cell: The underlying stateful node in the reactive graph. A namespace of static operator factories. Flow is deliberately NOT a CellBase: it has no cell state, no nucleus, and no participation in the reactive graph — it only assembles FlowInstruction blueprints. Keeping it out of the cell hierarchy prevents a fake cell from leaking into cell-typed positions.
AI Agent Guide
Layer: Flow — the static operator catalog. Not a Cell factory, not a Tissue book.
When to use: walk §3 families of HowTo-Mitose-Flow.md against the BRD before writing a custom instruction; Flow.* covers feed adapters and adjacent journeys.
When NOT to use: the decision gate of a Cell-variant Demo — that is FlowInstructionBase + + + toHandle (one Receptor, one lock).
Live signature: abstract class Flow — static factories return FlowHandle — pinned at cell_flow: 1.0.0
Do NOT confuse with: Cell (graph nodes; Flow is a namespace that only assembles blueprints).
Guide: HowTo-Mitose-Flow.md §3 "Examine the catalog against the BRD" (#flow-catalog)
Example: example/cell_flow_example.dart
Cross-layer: entry is Cell.ingress; books are cell_tissue; Cell.observe glues them.
Minimal compilable example
final src = Cell.ingress<int>();
final h = Flow.filter<int>(src.cell, test: (v) => v > 0);
final o = Cell.observe(source: h.cell, effect: (Pulse p) => print(p.payload));
src.emit(1);
o.stop();
Constructors
- Flow()
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
asyncExpand<
S, T> (Cell source, {required FutureOr< Object?> expand(S value), ExpandErrorHandler? onError}) → FlowHandle -
Flatten an inner sequence per payload (Dart
asyncExpand). -
asyncExpandConcurrent<
S, T> (Cell source, {required FutureOr< Object?> expand(S value), ExpandErrorHandler? onError}) → FlowHandle - Concurrent flatten.
-
asyncExpandExhaust<
S, T> (Cell source, {required FutureOr< Object?> expand(S value), ExpandErrorHandler? onError}) → FlowHandle - Exhaust flatten — ignore while busy.
-
asyncExpandLatest<
S, T> (Cell source, {required FutureOr< Object?> expand(S value), ExpandErrorHandler? onError}) → FlowHandle - Switch flatten — drop the previous inner.
-
asyncFold<
S, A> (Cell source, {required A seed, required FutureOr< A> accumulate(A acc, S value), FoldSnapshot<A> ? snapshot, FoldErrorHandler? onError}) → FlowHandle - Async running fold (queued).
-
asyncFoldExhaust<
S, A> (Cell source, {required A seed, required FutureOr< A> accumulate(A acc, S value), FoldSnapshot<A> ? snapshot, FoldErrorHandler? onError}) → FlowHandle - Similar to asyncFold, but ignores new triggers while an inner accumulation is already running.
-
asyncFoldLatest<
S, A> (Cell source, {required A seed, required FutureOr< A> accumulate(A acc, S value), FoldSnapshot<A> ? snapshot, FoldErrorHandler? onError}) → FlowHandle - Similar to asyncFold, but only processes the latest pulse.
-
asyncMap<
S, T> (Cell source, {required FutureOr< T> mapper(S value), AsyncMapErrorHandler? onError}) → FlowHandle -
Maps each payload through an asynchronous
mapper. -
asyncMapConcurrent<
S, T> (Cell source, {required FutureOr< T> mapper(S value), AsyncMapErrorHandler? onError}) → FlowHandle - Similar to asyncMap, but processes pulses concurrently as they arrive.
-
asyncMapLatest<
S, T> (Cell source, {required FutureOr< T> mapper(S value), AsyncMapErrorHandler? onError}) → FlowHandle - Similar to asyncMap, but only processes the latest pulse.
-
asyncMapWithFallback<
S, T> (Cell source, {required FutureOr< T> mapper(S value), required T fallback, AsyncMapErrorHandler? onError}) → FlowHandle -
Emit
fallbackwhen the mapper throws. -
asyncMapWithIndex<
S, T> (Cell source, {required FutureOr< T> mapper(S value, int index), AsyncMapErrorHandler? onError}) → FlowHandle - Async map with a 0-based index.
-
asyncMapWithRetry<
S, T> (Cell source, {required FutureOr< T> mapper(S value), int count = 3, AsyncMapErrorHandler? onError}) → FlowHandle -
Retry the mapper up to
countextra times. -
asyncMapWithTimeout<
S, T> (Cell source, {required FutureOr< T> mapper(S value), required Duration duration, AsyncMapErrorHandler? onError}) → FlowHandle - Time-box one projection.
-
asyncReduce<
S> (Cell source, {required FutureOr< S> accumulate(S acc, S value), FoldErrorHandler? onError}) → FlowHandle - First value is the seed; later values accumulate.
-
audit<
S> (Cell source, {required Cell notifier, SampleErrorHandler? onError}) → FlowHandle -
After a source value, emit it on the next
notifierpulse. -
auditTime<
S> (Cell source, {required Duration duration, SampleErrorHandler? onError}) → FlowHandle -
Emit the latest value
durationafter a source move. -
bufferCount<
S> (Cell source, {required int size, int? skip, BufferErrorHandler? onError}) → FlowHandle -
Collects payloads into a list and emits it once it reaches
size(RxbufferCount). -
bufferTime<
S> (Cell source, {required Duration duration, bool emitEmpty = false, BufferErrorHandler? onError}) → FlowHandle -
Periodically flushes the collected payloads into a list and emits it (Rx
bufferTime). -
bufferWhen<
S> (Cell source, {required Cell closer, bool emitEmpty = false, BufferErrorHandler? onError}) → FlowHandle -
Flush when
closerpulses. -
bufferWithPredicate<
S> (Cell source, {required bool test(S value), bool includeTrigger = true, BufferErrorHandler? onError}) → FlowHandle -
Close the buffer when
testis true. -
bufferWithTimeAndCount<
S> (Cell source, {required Duration duration, required int count, bool emitEmpty = false, BufferErrorHandler? onError}) → FlowHandle - Flush on count or duration.
-
combineLatestWith<
S, R> (Cell source, {required List< Cell> others, required R combine(S sourceValue, List<Object?> latest), CombineErrorHandler? onError}) → FlowHandle -
Combines the latest value from
sourcewith the latest values fromotherswhenever any of them emit. -
concat<
T> (Cell source, {required Iterable< Object?> inners, ConcatErrorHandler? onError}) → FlowHandle -
Play static inners after the first pulse (Rx
concat). -
concatAll<
T> (Cell source) → FlowHandle -
Each payload is an inner, queued (Rx
concatAll). -
concatLatest<
T> (Cell source) → FlowHandle - Last item of each inner.
-
concatMap<
S, T> (Cell source, {required FutureOr< Object?> project(S value)}) → FlowHandle -
Maps each payload to an inner sequence and flattens them sequentially
(Rx
concatMap). -
debounce<
S> (Cell source, {required Duration duration}) → FlowHandle -
Delays the emission of pulses until
durationhas passed since the last pulse (Rxdebounce). -
deferFuture<
S> (Cell source, {required Future< S> create(Pulse trigger), FutureErrorHandler? onError, bool emitErrorPulse = true}) → FlowHandle -
Executes
createto start a new future on every pulse received fromsource(Rxdeferfor futures). -
deferStream<
S> (Cell source, {required Stream< S> create(), StreamErrorHandler? onError, bool emitErrorPulse = true}) → FlowHandle -
Executes
createto subscribe to a new stream on every pulse received fromsource(Rxdeferfor streams). -
delay<
S> (Cell source, {required Duration duration, DelayErrorHandler? onError}) → FlowHandle -
Shift every value by
duration(Rxdelay). -
delayLatest<
S> (Cell source, {required Duration duration, DelayErrorHandler? onError}) → FlowHandle -
Only the latest value after
duration(trailing delay). -
delayWhen<
S> (Cell source, {required FutureOr< Object?> when(S value), DelayErrorHandler? onError}) → FlowHandle -
Wait for
whenbefore forwarding (RxdelayWhen). -
delayWithSelector<
S> (Cell source, {required Duration durationOf(S value), DelayErrorHandler? onError}) → FlowHandle - Per-value delay.
-
distinct<
S> (Cell source) → FlowHandle - Suppresses pulses that have been seen before (globally or consecutively depending on configuration).
-
exhaustMap<
S, T> (Cell source, {required FutureOr< Object?> project(S value)}) → FlowHandle -
Maps each payload to an inner sequence, but ignores new ones while a
sequence is already active (Rx
exhaustMap). -
filter<
S> (Cell source, {required bool test(S value)}) → FlowHandle -
Only forwards payloads that satisfy the
testpredicate (Rxfilter). -
fromFuture<
S> (Cell source, {required Future< S> future, Duration? timeout, FutureErrorHandler? onError, bool emitErrorPulse = true}) → FlowHandle -
Bridges a single
futureinto the graph on the first pulse received fromsource(RxfromFuture). -
fromIterable<
T> (Cell source, {required Iterable< T> iterable}) → FlowHandle -
Emits each element of
iterableon the first pulse received fromsource(Rxfrom). -
fromStream<
S> (Cell source, {required Stream< S> stream, StreamErrorHandler? onError, bool emitErrorPulse = true}) → FlowHandle -
Subscribes to
streamon the first pulse received fromsource(RxfromStream). -
groupBy<
S, K> (Cell source, {required K keyOf(S value), GroupErrorHandler? onError}) → FlowHandle -
Tag each value with
keyOf(RxgroupByflattened). -
groupByCount<
S, K> (Cell source, {required K keyOf(S value), required int size, GroupErrorHandler? onError}) → FlowHandle -
Emit a group's list when it hits
size. -
groupCollect<
S, K> (Cell source, {required K keyOf(S value), Map< K, List< ? groups, GroupErrorHandler? onError}) → FlowHandleS> > -
Running
Map<K, List<S>>. -
iif<
S, T> (Cell source, {required bool test(S value), required T thenMap(S value), required T elseMap(S value)}) → FlowHandle -
A binary router that chooses between
thenMapandelseMapbased ontest(Rxiif). -
interval(
Cell source, {required Duration period}) → FlowHandle - Periodic ticks after the first pulse.
-
map<
S, T> (Cell source, {required T project(S value), MapErrorHandler? onError}) → FlowHandle -
Projects each incoming payload through the
projectfunction (Rxmap). -
mapKeys<
K, V, R> (Cell source, {required R project(K key), MapErrorHandler? onError}) → FlowHandle - Payload is a Map; project each key.
-
mapNotNull<
S, T> (Cell source, {required T? project(S value), MapErrorHandler? onError}) → FlowHandle -
Projects each payload and suppresses the pulse if the result is
null. -
mapTo<
S, T> (Cell source, {required T value, MapErrorHandler? onError}) → FlowHandle -
Emits the constant
valuefor every pulse received fromsource(RxmapTo). -
mapValue<
S, T> (Cell source, {required T project(S value), MapErrorHandler? onError}) → FlowHandle - Alias of map using the MapValue name.
-
mapValueIf<
S, T> (Cell source, {required bool test(S value), required T project(S value), MapErrorHandler? onError}) → FlowHandle -
MapWhenunder the MapValue name. -
mapValueOr<
S, T> (Cell source, {required T project(S value), required T orElse(S value, Object error), MapErrorHandler? onError}) → FlowHandle -
Project, or
orElsewhenprojectthrows. -
mapValues<
K, V, R> (Cell source, {required R project(V value), MapErrorHandler? onError}) → FlowHandle - Payload is a Map; project each value.
-
mapWhen<
S, T> (Cell source, {required bool test(S value), required T project(S value), MapErrorHandler? onError}) → FlowHandle -
Project only when
testis true. -
mapWithIndex<
S, T> (Cell source, {required T project(S value, int index), MapErrorHandler? onError}) → FlowHandle - Projects each payload along with its 0-based index.
-
merge<
T> (Cell source, {required List< Cell> sources}) → FlowHandle -
Merge extra
sources;sourceonly armsfuture. -
mergeAll<
T> (Cell source, {MergeErrorHandler? onError}) → FlowHandle -
Payload is an inner to merge (Rx
mergeAll). -
mergeMap<
S, T> (Cell source, {required FutureOr< Object?> project(S value)}) → FlowHandle -
Maps each payload to an inner sequence and flattens them concurrently
(Rx
mergeMap). -
mergeWith<
T> (Cell source, {required List< Cell> others}) → FlowHandle -
Forward source and
others(RxmergeWith). -
of<
T> (Cell source, {required Iterable< T> values}) → FlowHandle -
Emits each value in
valuessequentially on the first pulse received fromsource(Rxof). -
pairwise<
S> (Cell source) → FlowHandle -
Emits a tuple of the
(previous, current)payloads for every pulse after the first. -
partition<
S> (Cell source, {required bool test(S value), PartitionErrorHandler? onError}) → FlowHandle -
Routes pulses based on whether they satisfy the
testpredicate. -
partitionMap<
S, T> (Cell source, {required bool test(S value), required T thenMap(S value), required T elseMap(S value), PartitionErrorHandler? onError}) → FlowHandle - Map matched / unmatched with different projectors.
-
partitionOnly<
S> (Cell source, {required bool test(S value), bool matched = true, PartitionErrorHandler? onError}) → FlowHandle - Keep only the matching side.
-
pluck<
T> (Cell source, {required Object key, PluckErrorHandler? onError}) → FlowHandle -
Extracts the value at
keyfrom a Map payload (Rxpluck). -
pluckAll(
Cell source, {required Iterable< Object> keys, Object? orElse, bool useOrElse = false, PluckErrorHandler? onError}) → FlowHandle - Pluck several keys into a Map.
-
pluckOr<
T> (Cell source, {required Object key, required T orElse, PluckErrorHandler? onError}) → FlowHandle -
Pluck with
orElsewhen the field is missing. -
pluckPath<
T> (Cell source, {required Iterable< Object> path, T? orElse, bool useOrElse = false, PluckErrorHandler? onError}) → FlowHandle -
Walk a nested
path. -
race<
T> (Cell source, {required List< Object?> competitors}) → FlowHandle -
First inner to emit wins (Rx
race). -
range(
Cell source, {required int start, required int count, int step = 1}) → FlowHandle -
Emits a range of
countintegers starting fromstarton the first pulse received fromsource(Rxrange). -
reduce<
S, A> (Cell source, {required A seed, required A accumulate(A acc, S value)}) → FlowHandle -
Similar to scan, but uses an explicit
seedvalue to initialize the accumulator. -
repeat<
T> (Cell source, {required T value, int count = 1}) → FlowHandle -
Emits the same
value,counttimes, on the first pulse received fromsource. -
retry<
S, T> (Cell source, {required RetryTask< S, T> task, int count = 3, RetryErrorHandler? onError, bool emitErrorPulse = true}) → FlowHandle - Retry a failing inner.
-
sample<
S> (Cell source, {required Cell notifier, SampleErrorHandler? onError}) → FlowHandle -
Latest source value when
notifierpulses. -
sampleTime<
S> (Cell source, {required Duration period, SampleErrorHandler? onError}) → FlowHandle -
Latest source value every
period. -
scan<
S, A> (Cell source, {required A accumulate(A acc, S value)}) → FlowHandle -
Applies an
accumulatefunction over the pulses, emitting each intermediate result (Rxscan). -
Multicasts the same pulses to all observers (Rx
share). - Share with a replay buffer.
-
skip<
S> (Cell source, {required int count}) → FlowHandle -
Suppresses the first
countpulses received fromsource. -
skipRepeated<
S> (Cell source) → FlowHandle - Suppresses pulses if their payload is identical to the previous payload.
-
skipUntil<
S> (Cell source, {required Cell notifier}) → FlowHandle -
Skip until
notifierpulses. -
skipWhen<
S> (Cell source, {required bool test(S value)}) → FlowHandle -
Drop values while
testis true. -
skipWhile<
S> (Cell source, {required bool test(S value)}) → FlowHandle -
Skip while
testis true. -
startWith<
S> (Cell source, {required S value, bool replaceFirst = false}) → FlowHandle -
Prepends the given
valueto the sequence before any pulses fromsourceare emitted (RxstartWith). -
switchMap<
S, T> (Cell source, {required FutureOr< Object?> project(S value)}) → FlowHandle -
Maps each payload to an inner sequence and always switches to the
latest one (Rx
switchMap). -
take<
S> (Cell source, {required int count}) → FlowHandle -
Only forwards the first
countpulses received fromsource. -
takeUntil<
S> (Cell source, {required Cell notifier}) → FlowHandle -
Take until
notifierpulses. -
takeWhile<
S> (Cell source, {required bool test(S value)}) → FlowHandle -
Take while
testis true. -
tap<
S> (Cell source, {required void onValue(S value), TapErrorHandler? onError}) → FlowHandle -
Executes a side effect
onValuefor every pulse without modifying the sequence (Rxtap). -
tapAll(
Cell source, {required void onPulse(Pulse pulse), TapErrorHandler? onError}) → FlowHandle - Tap every pulse, including wrong types.
-
tapWithIndex<
S> (Cell source, {required void onValue(S value, int index), TapErrorHandler? onError}) → FlowHandle - Tap with a 0-based index.
-
throttle<
S> (Cell source, {required Duration duration, bool leading = true, bool trailing = false}) → FlowHandle -
Limits the rate of emissions by enforcing a silent window of
durationafter a pulse. -
timeout<
S> (Cell source, {required Duration duration, TimeoutErrorHandler? onError, bool emitErrorPulse = true}) → FlowHandle - Idle timeout after the last pulse.
-
timeoutWithFallback<
S> (Cell source, {required Duration duration, required S fallback, bool once = false}) → FlowHandle - Timeout with a fallback value.
-
windowCount<
S> (Cell source, {required int size, int? skip}) → FlowHandle - Window by count (list payload).
-
windowTime<
S> (Cell source, {required Duration duration}) → FlowHandle - Window by time.
-
withLatestFrom<
S, R> (Cell source, {required List< Cell> others, required R combine(S sourceValue, List<Object?> latest), CombineErrorHandler? onError}) → FlowHandle -
Combines the latest value from
sourcewith the latest values fromothersonly whensourceemits (RxwithLatestFrom). -
zip<
R> (Cell source, {required List< Cell> sources, R project(List<Object?> row)?, ZipErrorHandler? onError}) → FlowHandle -
Zip extra
sources;sourcearmsfuture. -
zipAll<
T> (Cell source, {required int width, ZipErrorHandler? onError}) → FlowHandle -
Pack
widthsource values into a list. -
zipWith<
R> (Cell source, {required List< Cell> others, R project(List<Object?> row)?, ZipErrorHandler? onError}) → FlowHandle -
Zip
sourcewithothersby index (RxzipWith).