A simple state management library.

Getting started

Add hstate to your pubspec.yaml file:

dependencies:
  hstate:

Import:

import 'package:hstate/hstate.dart';

Usage

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

void main() => runApp(CounterApp());

// 1. init observable data anywhere, example the data layer
var counter = Observer(0);

class CounterApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          // 2. build widget from data
          child: counter.build((value) => Text(value.toString(), textAlign: TextAlign.center)),
        ),
        floatingActionButton: FloatingActionButton(onPressed: () {
          // 3. update value & notify change
          counter.value++;
          counter.notify();
        }),
      ),
    );
  }
}

Libraries

hstate