pureflow_flutter library

Usage

With ValueListenableBuilder

The simplest way to use Pureflow with Flutter is through the asListenable extension:

import 'package:pureflow/pureflow.dart';
import 'package:pureflow_flutter/pureflow_flutter.dart';

class CounterPage extends StatelessWidget {
  final counter = Store<int>(0);

  @override
  Widget build(BuildContext context) {
    return ValueListenableBuilder<int>(
      valueListenable: counter.asListenable,
      builder: (context, value, child) {
        return Text('Count: $value');
      },
    );
  }
}

With AnimatedBuilder

Since ValueListenable extends Listenable, you can use Pureflow stores with any widget that accepts a Listenable:

AnimatedBuilder(
  animation: counter.asListenable,
  builder: (context, child) => Text('${counter.value}'),
);

With Computed Values

Computed values work the same way:

final firstName = Store<String>('John');
final lastName = Store<String>('Doe');
final fullName = Computed(() => '${firstName.value} ${lastName.value}');

// In widget
ValueListenableBuilder<String>(
  valueListenable: fullName.asListenable,
  builder: (context, name, child) => Text('Hello, $name!'),
);

Performance

The ValueObservableAdapter adapter is designed for zero overhead:

  • No additional memory allocation per access
  • Instances are cached per source using Expando
  • Direct delegation to Pureflow's listener system

Classes

Computed<T>
A derived reactive value that automatically tracks its dependencies and recomputes lazily when they change.
FlowObserver
A global observer for monitoring Pureflow reactive primitives.
Observable
An object that maintains a list of listeners and notifies them when changes occur.
Pipeline
A pipeline for executing asynchronous tasks with controlled concurrency.
PipelineEventContext
Context object passed to pipeline tasks providing access to cancellation state.
Pureflow
Global entry point for Pureflow configuration.
ReactiveValueObservable<T>
A ValueObservable that also implements Stream for reactive data binding.
Store<T>
A reactive store that holds a single mutable value.
ValueObservable<T>
An Observable that holds a readable value of type T.
ValueObservableAdapter<T>
A zero-allocation adapter that exposes a Pureflow ValueObservable as a Flutter ValueListenable.

Enums

FlowKind
The kind of Pureflow reactive primitive.

Functions

batch<R>(R action()) → R
Runs a function within a batch context, deferring all notifications.
concurrent<E, R>() → EventTransformer<E, R>
droppable<E, R>() → EventTransformer<E, R>
restartable<E, R>() → EventTransformer<E, R>
sequential<E, R>() → EventTransformer<E, R>

Typedefs

EventMapper<E, R> = Stream<R> Function(E event)
A function that maps a single event to a stream of results.
EventTransformer<E, R> = Stream<R> Function(Stream<E> source, Stream<R> process(E event))
A function that transforms a stream of events using a processing function.