From 628ea99883a460f437d4337e189cd41d778cc2a2 Mon Sep 17 00:00:00 2001 From: Lev Nazarov Date: Fri, 18 May 2018 14:12:22 +0300 Subject: [PATCH 1/2] Nasty C# brackets & line optimization (82 lines milestone) --- lib/main.dart | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 3731244..eb7a895 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,4 @@ import 'dart:math'; - import 'package:flutter/material.dart'; void main() => runApp(new MyApp()); @@ -13,10 +12,8 @@ typedef OperatorFunc = double Function(double accu, double operand); class MyAppState extends State { - 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) { @@ -25,14 +22,10 @@ class MyAppState extends State { } 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(); @@ -86,6 +79,4 @@ class MyAppState extends State { ) ); } -} - - +} \ No newline at end of file From f2674d5f9eaeaf232ba5967d5fe0a412c51e26f0 Mon Sep 17 00:00:00 2001 From: Lev Nazarov Date: Fri, 18 May 2018 14:12:59 +0300 Subject: [PATCH 2/2] 80 lines hooray --- lib/main.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index eb7a895..508974f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,5 @@ import 'dart:math'; import 'package:flutter/material.dart'; - void main() => runApp(new MyApp()); class MyApp extends StatefulWidget { @@ -11,7 +10,6 @@ class MyApp extends StatefulWidget { typedef OperatorFunc = double Function(double accu, double operand); class MyAppState extends State { - double accu = 0.0, operand = 0.0; OperatorFunc queuedOperation; String resultString = "0.0";