From 7880da056a4549ce767f64d99bc9fcfa49945c83 Mon Sep 17 00:00:00 2001 From: Kaj Rusilowski <2020804@stud.hs-mannheim.de> Date: Tue, 9 Apr 2024 21:26:46 +0200 Subject: [PATCH] added decrement function and button --- lib/main.dart | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index dd5cc9d..a50cd80 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -38,6 +38,12 @@ class _MyHomePageState extends State { }); } + void _decrementCounter() { + setState(() { + _counter--; + }); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -59,10 +65,28 @@ class _MyHomePageState extends State { ], ), ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: const Icon(Icons.add), + floatingActionButton: Stack( + children: [ + Padding( + padding: EdgeInsets.only(left: 31), + child: Align( + alignment: Alignment.bottomLeft, + child: FloatingActionButton( + onPressed: _incrementCounter, + tooltip: 'Increment', + child: const Icon(Icons.add), + ), + ), + ), + Align( + alignment: Alignment.bottomRight, + child: FloatingActionButton( + onPressed: _decrementCounter, + tooltip: 'Decrement', + child: const Icon(Icons.remove), + ), + ), + ], ), ); }