FLUTTER ECOSYSTEM

firasdarwish/hydro

Flutter用のシンプルな状態管理およびサービスコンテナのソリューション。

hydro のプロジェクト画像
Stars
0
Forks
0
最終プッシュ(UTC)
2022/07/02
プロジェクト状態
公開中
Firas M. Darwish GitHub avatar
GITHUB User

Firas M. Darwish ↗

Software Developer

言語DartHTMLSwiftKotlinObjective-C

技術トピック

このリポジトリが公開するパッケージ

使用している依存関係

依存関係一覧 4 件

元の README

以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。

README を開く / 閉じる

hydro

A simple state management & service container solution for Flutter.

Usage
import 'package:hydro/hydro.dart';
// 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.
  }
  
}
// 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);
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>();