Search packages, repositories and app categories

Package detailsv2.3.0

vxstate

VxState is an another state management solution for flutter. It is highly inspired from Redux & VueX.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
5.8K
Likes
31
Pub points
160

Install package

flutter pub add vxstate

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

VxState is a state management solution for Flutter, inspired by Redux and VueX. It provides a predictable, centralized store for managing application state with a unidirectional data flow. Designed for scalability and simplicity, it supports reactive updates and integrates well with Flutter's widget tree. VxState emphasizes clean architecture and developer experience through concise APIs and consistent patterns. It works across all major platforms including Android, iOS, Web, macOS, Windows, and Linux.

Use cases

  • Managing global app state
  • Implementing predictable state changes
  • Scaling large Flutter applications
  • Integrating with reactive UIs
  • Simplifying complex state logic
  • Supporting cross-platform apps

Key features

  • Redux-like unidirectional data flow
  • VueX-inspired store structure
  • Reactive state updates
  • Cross-platform compatibility
  • Clean and minimal API
  • Built-in dev tools support

Suitable for

  • Developers familiar with Redux or VueX
  • Teams building large-scale Flutter apps
  • Projects requiring predictable state management
  • Apps needing strong debugging capabilities
  • Developers valuing consistency and structure

Considerations

  • May have a steeper learning curve for beginners
  • Requires understanding of state patterns
  • Overkill for very simple apps
  • Limited community resources compared to popular alternatives
  • Not as widely adopted as Provider or Riverpod

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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

Categories

Source repository

Projects using this package