speedex 0.0.3 speedex: ^0.0.3 copied to clipboard
SpeedEx, short for Speed Execution is a lightweight, efficient state management solution for Flutter. SpeedEx offers global state handling, computed values, middleware support, and more with minimal b [...]
import 'package:flutter/material.dart';
import 'package:speedex/speedex.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'SpeedEx Example',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'SpeedEx Example Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
void initState() {
super.initState();
SpeedEx.initialize();
SpeedEx.setValue('counter', 0);
}
void _incrementCounter() {
int currentValue = SpeedEx.getValue('counter') ?? 0;
SpeedEx.setValue('counter', currentValue + 1);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
SpeedExWidget<int>(
stateKey: 'counter',
builder: (context, value) {
return Text(
'${value ?? 0}',
style: Theme.of(context).textTheme.headlineMedium,
);
},
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}