Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sbntt/swc_flutter
https://github.com/sbntt/swc_flutter
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sbntt/swc_flutter
- Owner: SBNTT
- License: mit
- Created: 2020-03-17T18:43:11.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-05-20T09:01:24.000Z (over 2 years ago)
- Last Synced: 2023-12-03T18:23:27.095Z (about 1 year ago)
- Language: Dart
- Size: 93.8 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# State Widget Controller
![CI](https://github.com/SBNTT/swc_flutter/workflows/CI/badge.svg)
[![pub package](https://img.shields.io/pub/v/swc_flutter.svg)](https://pub.dev/packages/swc_flutter)
[![codecov](https://codecov.io/gh/SBNTT/swc_flutter/branch/master/graph/badge.svg)](https://codecov.io/gh/SBNTT/swc_flutter)```dart
class CountState with ChangeNotifier {int _value = 0;
increment() {
_value++;
notifyListeners();
}int get() => _value;
}
``````dart
class MyHomePage extends SwcStatelessWidget {@override
getProviders() => [
ChangeNotifierProvider(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(builder: (context, state, _) {
return Text(state.get().toString());
}),
),
floatingActionButton: FloatingActionButton(
onPressed: () => controller.onAddButtonClick(context),
child: const Icon(Icons.add),
),
);
}}
``````dart
class MyHomePageController extends SwcController {@override
init(BuildContext context) {
// ignore: avoid_print
print('init my home page');
}onAddButtonClick(BuildContext context) {
dispatch(context, (state) => state.increment());
}
}
```