holders 0.1.0
holders: ^0.1.0 copied to clipboard
Lightweight reactive value holders for Flutter with linked values, notifications, timing controls, and builder widgets.
import 'package:flutter/material.dart';
import 'package:holders/holders.dart';
void main() => runApp(const HoldersExample());
class HoldersExample extends StatefulWidget {
const HoldersExample({super.key});
@override
State<HoldersExample> createState() => _HoldersExampleState();
}
class _HoldersExampleState extends State<HoldersExample> {
final counter = ValueHolder<int>(0, isEqual: nativeIsEqual);
@override
void dispose() {
counter.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Holders example')),
body: Center(
child: HolderBuilder(
holder: counter,
builder: (context) => Text(
'${counter.value}',
style: Theme.of(context).textTheme.displayLarge,
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: () => counter.value++,
child: const Icon(Icons.add),
),
),
);
}
}