easystate 0.0.13 copy "easystate: ^0.0.13" to clipboard
easystate: ^0.0.13 copied to clipboard

outdated

EasyState is the simplest and the easiest state management for Flutter.

EasyState #

  • EasyState is the easiest and the simplest Flutter state manager library for beginners.

  • This is not the perfect state manager, but will give you great understanding about what state management is.

  • To make EasyState simple,

    • It does not put the model instance into container unlike others do.
    • And so, it does not require a special widget builder specifiying generic type to rebiuld UI.
    • Hence, you don't need to learn those things and becomes deadly simple.
    • EasyState simply uses the fundamental StreamBuilder widget to rebuild UI.

Installation #

Add EasyState to your pubspec.yaml file:

dependencies:
  easystate:

then, import it

import 'package:get/get.dart';

Examples #

  • Define your model
class CountModel extends EasyState {
  int value = 0;
  increase() {
    value ++;
    update();
  }
}
CountModel countModel = CountModel();
  • And consume it with StreamBuidler.
StreamBuilder(
  stream: countModel.stream,
  initialData: countModel.stream,
  builder: (context, snapshot) => Text(
    snapshot.data.value.toString(),
    style: Theme.of(context).textTheme.headline4,
  ),
),
  • Experimental. You can use EasyBuilder which is merely a wrapper class of StreamBuilder.
EasyBuilder(
  builder: (context, snapshot) => Text(
    snapshot.data.value.toString(),
    style: Theme.of(context).textTheme.headline4,
  ),
  model: countModel,
),

But I don't recommend to use it because this is not a standard widget builder and you have to learn it.

  • More example.

    • You can listen the stream and do some logic things without update UI.
  StreamSubscription stream;

  @override
  void initState() {
    stream = countModel.stream.listen((value) => setState(() => null));
    super.initState();
  }

  @override
  void dispose() {
    stream.cancel();
    super.dispose();
  }

Reference #

Developers #

  • To develop easystate package, clond https://github.com/thruthesky/easystate in your project and test it.
3
likes
0
pub points
0%
popularity

Publisher

verified publishersonub.com

EasyState is the simplest and the easiest state management for Flutter.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, rxdart

More

Packages that depend on easystate