Search packages, repositories and app categories

Package detailsv1.0.4

power_state

A flutter state management solution with dependency injection. You can easily manage your state

AndroidiOSWebmacOSWindowsLinux
30-day downloads
102
Likes
14
Pub points
150

Install package

flutter pub add power_state

Package Overview

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

PowerState is a Flutter state management solution that integrates dependency injection to simplify state handling. It enables developers to manage application state efficiently while promoting clean, scalable code. With built-in dependency injection, it reduces boilerplate and enhances testability. The package supports all major platforms, making it ideal for cross-platform applications. Its intuitive API allows easy setup and seamless state updates across widgets.

Use cases

  • Cross-platform app state management
  • Dependency injection in Flutter apps
  • Simplifying complex state logic
  • Testing stateful components
  • Building scalable UI architectures
  • Reducing boilerplate in state handling

Key features

  • Built-in dependency injection
  • Cross-platform support
  • Minimal boilerplate
  • Easy state updates
  • Scalable architecture
  • Test-friendly design

Suitable for

  • Developers seeking integrated DI and state management
  • Teams building large-scale Flutter applications
  • Projects requiring maintainable state logic
  • Flutter beginners learning state management
  • Apps targeting multiple platforms

Considerations

  • Limited documentation available
  • Smaller community compared to popular alternatives
  • May require learning curve for new users
  • Not yet widely adopted in production
  • Potential for limited third-party plugin compatibility

Original README

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

Power State is a lightweight and flexible state management library for Flutter apps. It provides a simple and easy-to-use API that helps you manage the state of your app in a clean and efficient way. With Power State, you can easily manage your app's state and update your UI in real-time.

Usage

Step:1 Create a PowerController

Create a controller class that extends PowerController. This controller class will hold your application's state and provide methods to manipulate it.

Here's an example CounterController class:

import 'package:power_state/power_state.dart';

class CounterController extends PowerController {
  int count = 1;

  increment() {
    count++;
    notifyListeners();
  }
}

Step:2 Store controller

Instantiate your controller class using PowerVault.put() method:

final CounterController controller = PowerVault.put(CounterController());

Step:3 Use PowerBuilder and PowerSelector to access your state

Use PowerBuilder to listen for changes to your state and rebuild your UI. Use PowerSelector to select a specific value from your state and rebuild only when that value changes.:

PowerBuilder<CounterController>(
  builder: (countController) {
    return Text(countController.count.toString());
  },
),

PowerSelector<CounterController>(
  selector: () => controller.selectorValue,
  builder: (countController) {
    return Text(countController.selectorValue.toString());
  },
),

Step:4 Update your state

Update your state by calling methods on your controller and calling notifyListeners() to rebuild your UI.

controller.increment();
controller.update();

You can find a Controller that is being used by another page and redirect you to it.

final CounterController countController = PowerVault.find();

Deleting a controller

If you no longer need a controller, you can delete it from PowerVault using the PowerVault.delete() method. Here's an example of deleting the CounterController:

PowerVault.delete<CounterController>();

Deleting all controller

If you no longer need controllerr, you can delete it from PowerVault using the PowerVault.clear() method. Here's an example of clear controllers:

PowerVault.clear();

Check out the example app to see Power State in action.

Categories

Source repository

Projects using this package

No data available yet.