Skip to main content

arctium_msg 0.3.0 copy "arctium_msg: ^0.3.0" to clipboard
arctium_msg: ^0.3.0 copied to clipboard

Set of integrations with Arctium SL aimed to further reducing boilerplate and making usage of those two packages seamless

example/lib/main.dart

import 'package:arctium_msg/arctium_msg.dart';
import 'package:flutter/material.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 {
  @override
  Widget build(BuildContext context) => StoreInjector<int>(
        store: () => StoreA(initialModel: 0),
        builder: (_, store) => Scaffold(
          appBar: AppBar(
            title: Text("Arctium Msg example"),
          ),
          body: Center(
            child: CounterBody(),
          ),
        ),
      );
}

class CounterBody extends StatelessWidget {
  @override
  Widget build(BuildContext context) => Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Binder<int>(
            (model) => Text("Current value: $model"),
          ),
          OutlinedButton(
            onPressed: () => send<int>(IncrementMsg(2)),
            child: Text("Increment"),
          ),
          OutlinedButton(
            onPressed: () => send<int>(DecrementMsg(1)),
            child: Text("Decrement"),
          ),
        ],
      );
}
0
likes
130
points
42
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Set of integrations with Arctium SL aimed to further reducing boilerplate and making usage of those two packages seamless

Repository (GitHub)

License

MIT (license)

Dependencies

arctium, flutter, flutter_msg

More

Packages that depend on arctium_msg