Import the Calculation into the main source code by adding, at the top of main.dart, the following:
| import "calculator.dart"; |
You need to define a Calculation object for the _CalculatorHomePageState so, below:
| String _str = "0"; |
You need to add:
| var _calculation = Calculation(); |
You will also need to properly implement the _CalculatorHomePageState’s add, deleteOne, and deleteAll methods, which will have to be calls to setState and the Calculation methods, like this:
| void add(String a) { |
| setState((){ |
| _calculation.add(a); |
| _str = _calculation.getString(); |
| }); |
| } |
| |
| void deleteAll() { |
| setState(() { |
| _calculation.deleteAll(); |
| _str = _calculation.getString(); |
| }); |
| } |
| |
| void deleteOne() { |
| setState(() { |
| _calculation.deleteOne(); |
| _str = _calculation.getString(); |
| }); |
| } |
| |
| void getResult() { |
| setState(() { |
| _str = _calculation.getResult().toString(); |
| }); |
| _calculation = new Calculation(); |
| } |