Last updated:
0 purchases
hstate
A simple state management library.
Getting started #
Add hstate to your pubspec.yaml file:
dependencies:
hstate:
copied to clipboard
Import:
import 'package:hstate/hstate.dart';
copied to clipboard
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();
}),
),
);
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.