Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

80 lines milestone #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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> {
)
);
}
}


}