hydro

Last updated:

0 purchases

hydro Image
hydro Images
Add to Cart

Description:

hydro

hydro #
A simple state management & service container solution for Flutter.
Usage #
import 'package:hydro/hydro.dart';
copied to clipboard
// inherit Hydro
class SomeClass extends Hydro {

String _name = "inital value";

// getter
String get name => _name;

// setter
void setName(String newName) {
_name = newName;
update(); // NOTE: `update()` is important to refresh the UI.
}

}
copied to clipboard
// Adding to the service container
// If already been added, nothing will change.
Hydro.set(SomeClass());

// OR

// force replace an existing service, set `forceReplace: true`
Hydro.set(SomeClass(), forceReplace: true);
copied to clipboard
class _SomePageState extends State<SomePage> {
// ...

SomeClass? some_class = Hydro.get<SomeClass>(this);
// OR
SomeClass some_class = Hydro.mustGet<SomeClass>(this);

// NOTE: `get` & `mustGet` methods accept an argument of type `State`,
// it is required to refresh the UI when changes occur;
// You may as well leave it empty if UI updates are NOT needed.
// SomeClass? some_class = Hydro.get<SomeClass>();
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.