flutter calculator app
build a calculator app in ios and android with the same code by using flutter.
structure
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.