パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v2.3.0

vxstate

VxState は、Flutter用の別の状態管理ソリューションです。Redux および VueX から強くインスパイアされています。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
5820
いいね数
31
Pub ポイント
160

パッケージをインストール

flutter pub add vxstate

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

VxState は、Redux や VueX にインスパイアされた Flutter の状態管理ソリューションです。予測可能で中央集約型のストアを提供し、一方向のデータフローでアプリケーションの状態を管理します。拡張性とシンプルさを重視して設計されており、リアクティブな更新をサポートし、Flutter のウィジェットツリーと良好に統合されます。VxState は、簡潔な API と一貫したパターンを通じて、クリーンアーキテクチャと開発者体験を強調しています。Android、iOS、Web、macOS、Windows、Linux を含むすべての主要プラットフォームで動作します。

用途

  • グローバルなアプリ状態の管理
  • 予測可能な状態変更の実装
  • 大規模なFlutterアプリケーションのスケーリング
  • リアクティブUIとの統合
  • 複雑な状態ロジックの簡素化
  • クロスプラットフォームアプリのサポート

主な機能

  • Redux風の単方向データフロー
  • VueX を参考にしたストア構造
  • リアクティブな状態の更新
  • クロスプラットフォーム互換性
  • 洗練された最小限の API
  • 組み込み開発ツールのサポート

適している対象

  • Redux や VueX に精通した開発者
  • 大規模なFlutterアプリを構築するチーム
  • 予測可能な状態管理を必要とするプロジェクト
  • 強力なデバッグ機能を必要とするアプリ
  • 一貫性と構造を重視する開発者

注意事項

  • 初心者にとっては学習曲線がより急峻になる可能性があります
  • 状態パターンの理解が必要です
  • 非常にシンプルなアプリには過剰です
  • 人気の代替品と比べてコミュニティリソースが限られている
  • Provider や Riverpod ほど広く採用されていない

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

VxState

VxState is a state management library built for Flutter apps with focus on simplicity. It is inspired by StoreKeeper & libraries like Redux, Vuex etc with the power of streams. Here is a basic idea of how it works:

  • Single Store (Single source of truth) to keep app's data
  • Structured modifications to store with Mutations
  • Widgets listen to mutations to rebuild themselves
  • Enhance this process with Interceptors and Effects

Core of VxState is based on the InheritedModel widget from Flutter.

Getting started

Add to your pubpsec:

dependencies:
  ...
  vxstate: any

Create a store:

import 'package:vxstate/vxstate.dart';

class MyStore extends VxStore {
  int count = 0;
}

Define mutations:

class Increment extends VxMutation<MyStore> {
  perform() => store.count++;
}

Listen to mutations:

@override
Widget build(BuildContext context) {
  // Define when this widget should re render
  VxState.watch(context, on: [Increment]);

  // Get access to the store
  MyStore store = VxState.store as MyStore;

  return Text("${store.count}");
}

Complete example:

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

// Build store and make it part of app
void main() {
  runApp(VxState(
    store: MyStore(),
    child: MyApp(),
  ));
}

// Store definition
class MyStore extends VxStore {
  int count = 0;
}

// Mutations
class Increment extends VxMutation<MyStore> {
  perform() => store.count++;
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // Define when this widget should re render
    VxState.watch(context, on: [Increment]);

    // Get access to the store
    MyStore store = VxState.store as MyStore;

    return MaterialApp(
      home: Scaffold(
        body: Column(
          children: <Widget>[
            Text("Count: ${store.count}"),
            RaisedButton(
              child: Text("Increment"),
              onPressed: () {
                // Invoke mutation
                Increment();
              },
            ),
          ],
        ),
      ),
    );
  }
}

Documentation

  • VxStore - Where your apps's data is kept
  • VxMutation - Logic that modifies Store
  • VxBuilder, VxNotifier, VxConsumer - Useful widgets for special cases
  • VxEffect - Chained mutations
  • VxInterceptors - Intercept execution of mutations

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト