Professional Documents
Culture Documents
dart';
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
title: "Calculator",
home: HomePage1(),
theme: ThemeData(
primarySwatch: Colors.teal,
),
));
}
@override
_HomePage1State createState() => _HomePage1State();
}
if (operation == '-') {
result = (firstnumber - sceondnumber).toString();
}
if (operation == 'x') {
result = (firstnumber * sceondnumber).toString();
}
if (operation == '%') {
result = (firstnumber % sceondnumber).toString();
} else
result = int.parse(textdisply + bt).toString();
}
setState(() {
textdisply = result;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Center(child: Text("Calculator..")),
),
body: Container(
child: Padding(
padding: const EdgeInsets.all(18.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Expanded(
child: Container(
child: Padding(
padding: EdgeInsets.all(30.0),
child: Text(
"$textdisply",
style: TextStyle(fontSize: 38),
),
),
alignment: Alignment.bottomRight,
),
),
Row(
children: [
button("9"),
button("8"),
button("7"),
button("%"),
],
),
Row(
children: [
button("6"),
button("5"),
button("4"),
button("x"),
],
),
Row(
children: [
button("3"),
button("2"),
button("1"),
button("+"),
],
),
Row(
children: [
button("C"),
button("0"),
button("="),
button("-"),
],
),
],
),
),
),
);
}
}