Dart reactive state component inspired by popular state management libraries.
- Allows surgical/fine-grained UI updates in-sync with the data.
- Leveraging the use of Streams for Asynchronous data flows.
- ~100 lines of code minimizing large dependency maintenance.
Import the package repository as dependency:
# pubspec.yaml
dependencies:
flutter:
sdk: flutter
# ...
xyz:
git:
url: https://github.com/yuriusuonly/xyz
# ...Check the demos for sample data flow use cases.
// lib/main.dart
import 'package:flutter/material.dart';
import 'package:xyz/xyz.dart';
void main() => runApp(App());
class App extends StatelessWidget {
const App({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Builder(
builder: (context) => XYZ(() {
final counter = 0.state(); // Initialize the counter state.
return Scaffold(
body: Center(
child: Text('${counter.value}') // Render the counter state value.
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () => counter.value++, // Update the counter state value.
label: const Text('Increase')
)
);
})
)
);
}
}