flutter_msg 0.2.0 copy "flutter_msg: ^0.2.0" to clipboard
flutter_msg: ^0.2.0 copied to clipboard

A State Management package that helps implementing MVU-style UDF architecture without boilerplate

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) => MaterialApp(
        home: CounterScreen(),
      );
}

class IncrementMsg extends Msg<int> {
  IncrementMsg(int amount) : super(update: (current) => current + amount);
}

class DecrementMsg extends Msg<int> {
  DecrementMsg(int amount) : super(update: (current) => current - amount);
}

class CounterScreen extends StatelessWidget {
  static final store = Store(initialModel: 0);

  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(
          title: Text("Counter"),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              store.bind(
                (model) => Text("Current value: $model"),
              ),
              OutlinedButton(
                onPressed: () => store.send(IncrementMsg(2)),
                child: Text("Increment"),
              ),
              OutlinedButton(
                onPressed: () => store.send(DecrementMsg(1)),
                child: Text("Decrement"),
              ),
            ],
          ),
        ),
      );
}
1
likes
110
pub points
0%
popularity

Publisher

unverified uploader

A State Management package that helps implementing MVU-style UDF architecture without boilerplate

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, msg

More

Packages that depend on flutter_msg