Slide 17
Slide 17 text
© ZOZO, Inc. 17
構造理解
class CounterPage extends StatefulWidget {
const CounterPage({super.key});
@override
State createState() => _CounterPageState();
}
class _CounterPageState extends State {
final counter = Signal(0, name: 'counter');
@override
void dispose() {
counter.dispose();
super.dispose();
}
lib/main.dartの生成ファイル
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Computed')),
body: Center(
child: SignalBuilder(
builder: (context, child) {
return Text('Counter: ${counter.value}');
},
),
),
floatingActionButton: FloatingActionButton(
onPressed: () => counter.value++,
child: const Icon(Icons.add),
),
);
}
}