flutter_reacton 0.1.1 copy "flutter_reacton: ^0.1.1" to clipboard
flutter_reacton: ^0.1.1 copied to clipboard

Flutter widgets and bindings for the Reacton state management library. Provides ReactonScope, ReactonBuilder, context.watch(), and more.

example/example.dart

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

// Define reactons at the top level.
final counterReacton = reacton(0, name: 'counter');
final doubleCountReacton = computed(
  (read) => read(counterReacton) * 2,
  name: 'doubleCount',
);

void main() => runApp(ReactonScope(child: const CounterApp()));

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: const CounterPage(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    // context.watch subscribes and rebuilds on change.
    final count = context.watch(counterReacton);
    final doubled = context.watch(doubleCountReacton);

    return Scaffold(
      appBar: AppBar(title: const Text('Reacton Counter')),
      body: Center(
        child: Text('Count: $count (x2 = $doubled)'),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () => context.update(counterReacton, (n) => n + 1),
        child: const Icon(Icons.add),
      ),
    );
  }
}
0
likes
0
points
44
downloads

Publisher

verified publishersitharaj.in

Weekly Downloads

Flutter widgets and bindings for the Reacton state management library. Provides ReactonScope, ReactonBuilder, context.watch(), and more.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, reacton

More

Packages that depend on flutter_reacton