Skip to content
Functional listener/observable widgets (FLOWs). Propagate your state changes using stream controller broadcasts.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
lib
.gitignore
.metadata
CHANGELOG.md
LICENSE
README.md
pubspec.lock
pubspec.yaml

README.md

FLOW

Functional listener/observable widgets (FLOWs). Propagate your state changes using stream controller broadcasts.

Getting Started

import 'package:flutter/material.dart';
import 'package:flow/flow.dart';

final Map flows = {
  'tapCount': FLOW().stream(0),
};

final FLOW myHomePage = FLOW(
  ctl: flows['tapCount'],
  cnd: (val) => val % 2 == 0,
  builder: ({ctx, val}) => Scaffold(
    appBar: AppBar(
      title: Text(
        val == 0
          ? 'Hello world!'
          : 'The tap count is EVEN ($val)',
      ),
    ),
    body: Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          FLOW(
            ctl: flows['tapCount'],
            builder: ({ val, ctx }) => Text(
              val == 0
                ? 'Press the plus button to begin!'
                : 'Total Taps: $val',
            ),
          ),
        ],
      ),
    ),
    floatingActionButton: FloatingActionButton(
      onPressed: () {
        flows['tapCount'].current(flows['tapCount'].val + 1);
      },
      tooltip: 'Increment',
      child: Icon(Icons.add),
    ),
  ),
);

final FLOW myApp = FLOW(
  builder: ({ctx, val}) => MaterialApp(
    title: 'FLOW Demo',
    theme: ThemeData(
      primarySwatch: Colors.blue,
    ),
    home: myHomePage,
  ),
);

void main() => runApp(myApp);
You can’t perform that action at this time.