ffx 0.2.0
ffx: ^0.2.0 copied to clipboard
ffx is a brand new life cycle + state management tool in flutter. It is intended to solve the templating problem written by StatefulWidget, simplify the code, and improve work efficiency.
import 'package:ffx/ffx.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'FFx Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: FirstPage(),
);
}
}
class FirstPage extends XWidget {
FirstPage({super.key});
@override
Widget build(BuildContext context) {
final counter = x.remember(mutableIntStateOf(0));
return Scaffold(
appBar: AppBar(
backgroundColor: x.theme.colorScheme.inversePrimary,
title: const Text('FFx Demo'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
style: x.theme.textTheme.headlineSmall,
),
Text(
'${counter.value}',
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
counter.value = counter.value + 1;
},
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}