swc_flutter

Creator: coderz1093

Last updated:

0 purchases

swc_flutter Image
swc_flutter Images

Languages

Categories

Add to Cart

Description:

swc flutter

State Widget Controller #



class CountState with ChangeNotifier {

int _value = 0;

increment() {
_value++;
notifyListeners();
}

int get() => _value;

}
copied to clipboard
class MyHomePage extends SwcStatelessWidget<MyHomePageController> {

@override
getProviders() => [
ChangeNotifierProvider<CountState>(create: (_) => CountState()),
];

@override
getController() => MyHomePageController();

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('swc_flutter example app'),
),
body: Center(
child: Consumer<CountState>(builder: (context, state, _) {
return Text(state.get().toString());
}),
),
floatingActionButton: FloatingActionButton(
onPressed: () => controller.onAddButtonClick(context),
child: const Icon(Icons.add),
),
);
}

}
copied to clipboard
class MyHomePageController extends SwcController<MyHomePage> {

@override
init(BuildContext context) {
// ignore: avoid_print
print('init my home page');
}

onAddButtonClick(BuildContext context) {
dispatch<CountState>(context, (state) => state.increment());
}

}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.