easy 2.0.0 copy "easy: ^2.0.0" to clipboard
easy: ^2.0.0 copied to clipboard

outdated

An easy Flutter state managegement that allows minimal rebuild of widgets and improves performance.

Easy #

An easy Flutter state management that allows minimal rebuild of widgets and improves performance.

Getting Started #

Add EasyManager and your state class to Main:

example:

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

void main() {
  runApp(MaterialApp(home: MyApp()))
}

Create your business logic class by extending EasyBloc and store it in a variable. Automatically your IDE will prompt you to implement exec. Exec will immediately execute everything inside it, whether asynchronous or asynchronous. If you have asynchronous tasks, it will expect you to complete all tasks within the class, and then rebuild the views related to your class automatically.


final appBloc = AppBloc();
class AppBloc extends EasyBloc {
  int counter = 0;

  @override
  void exec() {
    counter++;
    super.exec();
  }
}

Use the Store widget. A magical widget that will identify any changes in your logical class, and rebuild the changed widget for you.

Important! In other state managers, you must enter ChangeNotifierProvider or another Provider as the parent of MaterialApp. With Easy this is not necessary. EasyManager just needs to be above the Store() widget anywhere in the widget tree.

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return EasyManager(
      bloc: appBloc,
      view: Scaffold(
          floatingActionButton: FloatingActionButton(
              child: Icon(Icons.add), onPressed: () => appBloc.exec()),
          body: Center(
            child: Store(rebuild:(_) => Text(
                "${appBloc.counter}",
                style: TextStyle(fontSize: 50),
              ),
            ),
          ),
        );
    )
  }
}

Ready! You created the default example that has more than 100 lines of code with only 30 lines, and still separated business logic from its UI. This is amazing!

If you navigate to another class, you can use the Store Widget to get the value of your logical class, as well as the Provider, and you can call dispose anytime you want using: variableName.dispose().

19
likes
0
points
36
downloads

Publisher

verified publishergetx.site

Weekly Downloads

An easy Flutter state managegement that allows minimal rebuild of widgets and improves performance.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on easy