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
17 changes: 3 additions & 14 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'dart:math';

import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
Expand All @@ -12,11 +10,8 @@ class MyApp extends StatefulWidget {
typedef OperatorFunc = double Function(double accu, double operand);

class MyAppState extends State<MyApp> {

double accu = 0.0;
double operand = 0.0;
double accu = 0.0, operand = 0.0;
OperatorFunc queuedOperation;

String resultString = "0.0";

void numberPressed(int value) {
Expand All @@ -25,14 +20,10 @@ class MyAppState extends State<MyApp> {
}

void calc(OperatorFunc operation) {
if (operation == null) // C was pressed
{
if (operation == null) // C was pressed
accu = 0.0;
}
else
{
accu = queuedOperation != null ? queuedOperation(accu, operand) : operand;
}
queuedOperation = operation;
operand = 0.0;
var result = accu.toString();
Expand Down Expand Up @@ -86,6 +77,4 @@ class MyAppState extends State<MyApp> {
)
);
}
}


}