import
'package:flutter/material.dart'
;
import
'package:flutter_simple_calculator/flutter_simple_calculator.dart'
;
void
main() => runApp(
const
RunMyApp());
class
RunMyApp extends StatelessWidget {
const
RunMyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return
MaterialApp(
debugShowCheckedModeBanner:
false
,
theme: ThemeData(primarySwatch: Colors.green),
home: Scaffold(
appBar: AppBar(
title:
const
Text(
'SimpleCalculator'
),
),
body: SizedBox(
width:
double
.infinity,
child: Calc(),
),
),
);
}
}
class
Calc extends StatefulWidget {
const
Calc({Key? key}) : super(key: key);
@override
_CalcState createState() => _CalcState();
}
class
_CalcState extends State<Calc> {
double
? _currentValue = 0;
@override
Widget build(BuildContext context) {
var calc = SimpleCalculator(
value: _currentValue!,
hideExpression:
false
,
hideSurroundingBorder:
true
,
autofocus:
true
,
onChanged: (key, value, expression) {
setState(() {
_currentValue = value ?? 0;
});
},
theme:
const
CalculatorThemeData(
borderColor: Colors.black,
borderWidth: 2,
displayColor: Colors.black54,
displayStyle:
TextStyle(fontSize: 80, color: Color.fromARGB(255, 18, 218, 24)),
expressionColor: Colors.indigo,
expressionStyle: TextStyle(fontSize: 20, color: Colors.white),
operatorColor: Color.fromARGB(255, 130, 192, 85),
operatorStyle: TextStyle(fontSize: 30, color: Colors.white),
commandColor: Colors.orange,
commandStyle: TextStyle(fontSize: 30, color: Colors.white),
numColor: Colors.grey,
numStyle: TextStyle(fontSize: 50, color: Colors.white),
),
);
return
SafeArea(child: calc);
}
}