diff --git a/lib/main.dart b/lib/main.dart index 8e94089..fa92b60 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -59,15 +59,17 @@ class _MyHomePageState extends State { void _incrementCounter() { setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. _counter++; }); } + // 새로운 메서드 추가: 카운터 감소 + void _decrementCounter() { + setState(() { + _counter--; + }); + } + @override Widget build(BuildContext context) { // This method is rerun every time setState is called, for instance as done @@ -115,11 +117,23 @@ class _MyHomePageState extends State { ], ), ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: const Icon(Icons.add), - ), // This trailing comma makes auto-formatting nicer for build methods. + floatingActionButton: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + // 감소 버튼 추가 + FloatingActionButton( + onPressed: _decrementCounter, + tooltip: 'Decrement', + child: const Icon(Icons.remove), + ), + const SizedBox(width: 10), // 버튼 간격 + FloatingActionButton( + onPressed: _incrementCounter, + tooltip: 'Increment', + child: const Icon(Icons.add), + ), + ], + ), ); } }