0% found this document useful (0 votes)
1 views

calculator not worked

This Flutter application provides a simple user interface for performing basic arithmetic operations (addition, subtraction, and multiplication) on two input numbers. Users can enter numbers in text fields and see the result displayed on the screen after pressing the corresponding operation button. The app uses state management to update the result dynamically based on user input.

Uploaded by

Shreelesh Pawar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

calculator not worked

This Flutter application provides a simple user interface for performing basic arithmetic operations (addition, subtraction, and multiplication) on two input numbers. Users can enter numbers in text fields and see the result displayed on the screen after pressing the corresponding operation button. The app uses state management to update the result dynamically based on user input.

Uploaded by

Shreelesh Pawar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

import 'package:flutter/material.

dart';

void main() {
runApp(MaterialApp(
home:MyApp()
)); // MaterialApp
}

class MyApp extends StatefulWidget {


const MyApp({super.key});

@override
State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {


TextEditingController controller1 = TextEditingController();
TextEditingController controller2 = TextEditingController();
int? num1=0,num2=0,result=0;
add() {
setState(() {
num1 = int.parse(controller1.text);
num2 = int.parse(controller2.text);
result = num1! + num2!;
});
}
sub(){
setState(() {
num1 = int.parse(controller1.text);
num2 = int.parse(controller2.text);
result = num1! - num2!;
});
}
mul(){
setState(() {
num1 = int.parse(controller1.text);
num2 = int.parse(controller2.text);
result = num1! * num2!;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title : Text('GOOD MORNING '),
backgroundColor: Colors.red.shade900,
), // AppBar
body: Column(
children: [
SizedBox(
height: 15,
),
TextField(
decoration: InputDecoration(
labelText: "Enter The First Number",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10000)
), // OutlineInputBorder
), //InputDecoration
), // TextField
SizedBox(
height: 20,
),
TextField(
decoration: InputDecoration(
labelText: "Enter The Second Number",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10000)
),
),
),
SizedBox(
height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(onPressed: (){add();}, child: Text('ADD')),
SizedBox(width: 15),
ElevatedButton(onPressed: (){sub();}, child: Text('SUB')),
SizedBox(width: 15),
ElevatedButton(onPressed: (){mul();}, child: Text('MUL'))
],
),
SizedBox(height: 15),
Text('Result is: $result',style: TextStyle(
fontSize: 20,fontWeight: FontWeight.bold,color: Colors.red

),
)
],
)
);
}
}

You might also like