Created
September 28, 2018 14:12
-
-
Save yadu-sayone/56869cebf5ba97b3dd41a409be7a4cb7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
backgroundColor: Theme.of(context).primaryColor, | |
body: SafeArea( | |
child: Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: Column( | |
children: <Widget>[ | |
Expanded( | |
child: Container( | |
child: Align( | |
alignment: Alignment.bottomRight, | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.end, | |
mainAxisAlignment: MainAxisAlignment.end, | |
children: <Widget>[ | |
operand1 != null | |
? SingleChildScrollView( | |
scrollDirection: Axis.horizontal, | |
child: Text( | |
operand1 is double | |
? operand1.toStringAsFixed(2) | |
: operand1.toString(), | |
style: _whiteTextStyle, | |
textAlign: TextAlign.right, | |
), | |
) | |
: Container(), | |
operator != null | |
? Text( | |
operator.toString(), | |
style: _whiteTextStyle, | |
textAlign: TextAlign.right, | |
) | |
: Container(), | |
operand2 != null | |
? Text( | |
operand2.toString(), | |
style: _whiteTextStyle, | |
textAlign: TextAlign.right, | |
) | |
: Container(), | |
result != null | |
? Divider( | |
height: 5.0, | |
color: Colors.white, | |
) | |
: Container(), | |
result != null | |
? SingleChildScrollView( | |
scrollDirection: Axis.horizontal, | |
child: Text( | |
result is double | |
? result.toStringAsFixed(2) | |
: result.toString(), | |
style: _whiteTextStyle, | |
textAlign: TextAlign.right, | |
), | |
) | |
: Container(), | |
], | |
), | |
), | |
), | |
), | |
Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: <Widget>[ | |
UnaryOperatorButton( | |
text: "AC", | |
onPressed: () { | |
_otherOperationAction(OtherOperation.clear); | |
}, | |
), | |
UnaryOperatorButton( | |
text: plus_or_minus_sign, | |
onPressed: (){_unaryOperationAction(UnaryOperation.changeSign);}, | |
), | |
UnaryOperatorButton( | |
text: percent_sign, | |
onPressed: (){_unaryOperationAction(UnaryOperation.percent);}, | |
), | |
BinaryOperatorButton( | |
text: divide_sign, | |
onPressed: () { | |
_binaryOperationAction(BinaryOperation.divide); | |
}, | |
) | |
], | |
), | |
Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: <Widget>[ | |
NumberButton( | |
text: "7", | |
onPressed: () { | |
_numberButtonAction("7"); | |
}), | |
NumberButton( | |
text: "8", | |
onPressed: () { | |
_numberButtonAction("8"); | |
}), | |
NumberButton( | |
text: "9", | |
onPressed: () { | |
_numberButtonAction("9"); | |
}), | |
BinaryOperatorButton( | |
text: multiply_sign, | |
onPressed: () { | |
_binaryOperationAction(BinaryOperation.multiply); | |
}, | |
) | |
], | |
), | |
Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: <Widget>[ | |
NumberButton( | |
text: "4", | |
onPressed: () { | |
_numberButtonAction("4"); | |
}), | |
NumberButton( | |
text: "5", | |
onPressed: () { | |
_numberButtonAction("5"); | |
}), | |
NumberButton( | |
text: "6", | |
onPressed: () { | |
_numberButtonAction("6"); | |
}), | |
BinaryOperatorButton( | |
text: minus_sign, | |
onPressed: () { | |
_binaryOperationAction(BinaryOperation.subtract); | |
}, | |
) | |
], | |
), | |
Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: <Widget>[ | |
NumberButton( | |
text: "1", | |
onPressed: () { | |
_numberButtonAction("1"); | |
}), | |
NumberButton( | |
text: "2", | |
onPressed: () { | |
_numberButtonAction("3"); | |
}), | |
NumberButton( | |
text: "3", | |
onPressed: () { | |
_numberButtonAction("3"); | |
}), | |
BinaryOperatorButton( | |
text: add_sign, | |
onPressed: () { | |
_binaryOperationAction(BinaryOperation.add); | |
}, | |
) | |
], | |
), | |
Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: <Widget>[ | |
ZeroButton(onPressed: (){_zeroButtonAction();},), | |
BinaryOperatorButton( | |
text: ".", | |
onPressed: () { | |
_otherOperationAction(OtherOperation.addDecimal); | |
}, | |
), | |
BinaryOperatorButton( | |
text: equal_sign, | |
onPressed: () { | |
_otherOperationAction(OtherOperation.equals); | |
}, | |
) | |
], | |
), | |
], | |
), | |
), | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment