joker_state 1.1.0+2
joker_state: ^1.1.0+2 copied to clipboard
Joker is a lightweight, reactive state management solution for Flutter that brings the fun of the circus to your codebase with simple, flexible, and type-safe state handling.
example/example.md
import 'package:flutter/material.dart';
import 'package:joker_state/joker_state.dart';
void main() {
// Register Joker globally
Circus.summon<int>(0, tag: 'counter');
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Find the registered Joker
final counter = Circus.spotlight<int>(tag: 'counter');
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('JokerState Demo')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('You have pushed the button this many times:'),
// Rebuild only when the state changes
counter.perform(
builder: (context, count) => Text(
'$count',
style: Theme.of(context).textTheme.headlineMedium,
),
),
],
),
),
floatingActionButton: FloatingActionButton(
// Update the state
onPressed: () => counter.trickWith((state) => state + 1),
tooltip: 'Increment',
child: Icon(Icons.add),
),
),
);
}
}