0 purchases
cute wm
Getting started #
In your flutter project add the dependency:
dependencies:
...
cute_wm:
copied to clipboard
Usage example #
Import flutter_cute.dart
import 'package:flutter_cute/flutter_cute.dart';
copied to clipboard
Create Widget #
class CounterPage extends CuteWidget<CounterWM> {
const CounterPage({
Key? key,
}) : super(key: key, wmFactory: CounterWM.factory);
@override
Widget build(CounterWM wm) {
return Scaffold(
appBar: AppBar(title: Text(wm.pageTitle)),
body: Center(
child: Column(
children: [
const SizedBox(height: 16),
ValueListenableBuilder(
valueListenable: wm.count,
builder: (_, count, __) => Text(
count.toString(),
style: wm.textTheme.headline4,
),
),
ElevatedButton(
onPressed: wm.increment,
child: const Text('Increment'),
),
],
),
),
);
}
}
copied to clipboard
Create WidgetModel #
class CounterWM extends WidgetModel {
CounterWM.factory(BuildContext context);
TextTheme get textTheme => Theme.of(context).textTheme;
final count = ValueNotifier<int>(0);
final pageTitle = 'Flutter cute demo';
@override
void init() => count.value = 15;
void increment() => count.value++;
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.