fast_rx 0.0.1 copy "fast_rx: ^0.0.1" to clipboard
fast_rx: ^0.0.1 copied to clipboard

outdated

An easy to understand reactive state management solution for Flutter

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  final _int = 0.rx;
  final _list = [0].rx;
  final _set = {0}.rx;
  final _map = {0: 0}.rx;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('fast_rx example'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text('Reactive int:'),
            FastBuilder(
              () => Text(
                '$_int',
                style: Theme.of(context).textTheme.headline4,
              ),
            ),
            const Text('Reactive list:'),
            FastBuilder(
              () => Text(
                '$_list',
                style: Theme.of(context).textTheme.headline4,
              ),
            ),
            const Text('Reactive set:'),
            FastBuilder(
              () => Text(
                '$_set',
                style: Theme.of(context).textTheme.headline4,
              ),
            ),
            const Text('Reactive map:'),
            FastBuilder(
              () => Text(
                '$_map',
                style: Theme.of(context).textTheme.headline4,
              ),
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: increment,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }

  void increment() {
    _int.value++;
    _list.add(_int.value);
    _set.add(_int.value);
    _map[_int.value] = _int.value;
  }
}
4
likes
0
pub points
46%
popularity

Publisher

verified publisherrexios.dev

An easy to understand reactive state management solution for Flutter

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on fast_rx