Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,17 @@ class _MyHomePageState extends State<MyHomePage> {

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
Expand Down Expand Up @@ -115,11 +117,23 @@ class _MyHomePageState extends State<MyHomePage> {
],
),
),
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),
),
],
),
);
}
}