dataflow 1.0.1
dataflow: ^1.0.1 copied to clipboard
A reactive state management library for Flutter with a simple and intuitive API which allows you to build Flutter applications with ease.
example/lib/main.dart
// main.dart
import 'package:dataflow/dataflow.dart';
import 'package:example/store.dart';
import 'package:flutter/material.dart';
import 'actions.dart';
import 'login_widget.dart';
import 'todo_widget.dart';
void main() {
final store = AppStore();
DataFlow.init(store);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Login and Todo App')),
body: DataSync<AppStore>(
builder: (context, store, statuses) {
if (statuses.values
.any((status) => status == DataActionStatus.error)) {
return const Center(child: Text('An error occurred'));
} else if (statuses.values
.any((status) => status == DataActionStatus.loading)) {
return const Center(child: CircularProgressIndicator());
}
return store.isLoggedIn ? TodoScreen() : LoginScreen();
},
actions: const {LoginAction},
),
),
);
}
}