ffm 1.0.0 ffm: ^1.0.0 copied to clipboard
Flutter For Mobile
FFM #
Flutter For Mobile
Usage #
Split UI and logic, and provide connection to each other.
Easy state management with auto disposal.
import 'package:ffm/ff.dart';
import 'home-page-logic.dart';
class HomePage extends FPage<HomePageLogic> {
HomePage({Key? key}) : super(key: key) {
setLogic(HomePageLogic());
}
@override
Widget buildLayout(BuildContext context) {
return Scaffold(
key: logic.scaffoldKey,
appBar: AppBar(
title: Text('Home'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text('You have pushed the button this many times:'),
logic.countPipe.onUpdate((val) => Text(
'$val',
style: Theme.of(context).textTheme.headline4,
)),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: logic.onClickAdd,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}
import 'package:ffm/ff.dart';
import 'home-page.dart';
import 'info-page.dart';
class HomePageLogic extends FPageLogic<HomePage> {
late FPipe<int> countPipe;
HomePageLogic() {
countPipe = FPipe(initValue: 0, disposer: disposer);
}
@override
void initState() {}
@override
void onBuildLayout() {}
@override
void onLayoutLoaded() {}
void onClickAdd() async {
countPipe.update(countPipe.value + 1);
if (countPipe.value == 3) {
countPipe.update(0);
var value = await pageOpen<int>(InfoPage());
}
}
}
[//]: # ( Flutter Commands
- Get all dependencies: $ fvm flutter pub get )