june 0.7.9 copy "june: ^0.7.9" to clipboard
june: ^0.7.9 copied to clipboard

Simple State Manager is all you need

pub package

Simple is all you need #

Why use complex and bulky state management?
What you need is simple and easy, yet it fully satisfies all your requirements when building an app.

And that state management is right here.

June #

June is an easy-to-use and intuitive lightweight state management library that has all the features needed when creating an app.

Usage #

  1. Declare the states.
class CounterVM extends JuneDataClass {
  int count = 0;
}
  1. The state management wraps the widget to be managed with JuneUpdater.
JuneUpdater(
  () => CounterVM(),
  child: (vm) => Column(
    mainAxisAlignment: MainAxisAlignment.center,
    children: <Widget>[
      Text('${vm.count}'
      ),
    ],
  ),
)
  1. Update the states using the June.get method.
var viewModel = June.get(CounterVM());
viewModel.count++;

viewModel.update();
  1. That's All!

Example

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

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: JuneUpdater(
            () => CounterVM(),
            child: (vm) => Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                const Text('You have pushed the button this many times:'),
                Text(
                  '${vm.count}',
                  style: Theme.of(context).textTheme.headlineMedium,
                ),
              ],
            ),
          ),
        ),
        floatingActionButton: const FloatingActionButton(
          onPressed: incrementCounter,
          tooltip: 'Increment',
          child: Icon(Icons.add),
        ),
      ),
    );
  }
}

void incrementCounter() {
  var viewModel = June.get(CounterVM());
  viewModel.count++;

  viewModel.update();
}

class CounterVM extends JuneDataClass {
  int count = 0;
}

Advance #

Object State Management #

June offers the ability to create multiple instances of declared states as objects. This feature is extremely useful for managing different data in repetitive formats, such as feed content.

Simply add a tag to JuneUpdater and June.get to utilize this functionality.

Example

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

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: JuneUpdater(
            () => CounterVM(),
            tag: "SomeId",
            child: (vm) => Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                const Text('You have pushed the button this many times:'),
                Text(
                  '${vm.count}',
                  style: Theme.of(context).textTheme.headlineMedium,
                ),
              ],
            ),
          ),
        ),
        floatingActionButton: const FloatingActionButton(
          onPressed: incrementCounter,
          tooltip: 'Increment',
          child: Icon(Icons.add),
        ),
      ),
    );
  }
}

void incrementCounter() {
  var viewModel = June.get(CounterVM(), tag: "SomeId");
  viewModel.count++;

  viewModel.update();
}

class CounterVM extends JuneDataClass {
  int count = 0;
}
52
likes
0
pub points
80%
popularity

Publisher

verified publisherjunelee.fun

Simple State Manager is all you need

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on june