flutter
calculator app
build a calculator app in ios and android with the same code by using flutter.
![[2025] A Simple Flutter Calculator App a simple flutter calculator app](https://i0.wp.com/flutterawesome.com/content/images/2018/10/flutter_calculator.gif?w=770&ssl=1)
structure
![[2025] A Simple Flutter Calculator App flutter_calculatorv](https://i0.wp.com/flutterawesome.com/content/images/2018/10/flutter_calculatorv.jpg?w=770&ssl=1)
input widgets
input widgets is all extends statefulwidget, because they need to response the ontap gesture.
- numberbutton. rendering the number button (like 1,2,3…) and handling the ontap gesture.
- operatorbutton. rendering the operator button (like +,-,*…) and handling the ontap gesture.
- resultbutton. rendering the command button (like clear,equal…) and handling the ontap gesture.
output widgets
output widgets is all extends statelesswidget, because they are just rendering.
- resultdisplay. rendering the current result and changing display when user tap a number button.
- historyblock. rendering the calculation histories and changing display every time when user tap a valid button.
calculator page
calculatorpage is extends statefulwidget and holding the list of result.
it receives every input widgets ontap event, makes a logical calculation for these inputs and decides what to display to output widgets.
Comments are closed.