-
Notifications
You must be signed in to change notification settings - Fork 0
/
bmi.dart
74 lines (70 loc) · 2.11 KB
/
bmi.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import 'package:flutter/material.dart';
class BMI extends StatefulWidget {
const BMI({super.key});
@override
State<BMI> createState() => _BMIState();
}
class _BMIState extends State<BMI> {
TextEditingController usd = TextEditingController();
TextEditingController inr = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Conversion'),
backgroundColor: Colors.blueAccent,
),
body: Padding(
padding: const EdgeInsets.all(10),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
TextField(
controller: usd,
onChanged: (val) {
if (val.isNotEmpty) {
inr.text = (double.parse(val) * 80).toString();
}
},
keyboardType: TextInputType.number,
decoration: InputDecoration(
label: const Text('USD'),
hintText: '100',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(30),
),
),
),
const SizedBox(height: 10),
TextField(
controller: inr,
onChanged: (val) {
if (val.isNotEmpty) {
usd.text = (double.parse(val) / 80).toString();
}
},
keyboardType: TextInputType.number,
decoration: InputDecoration(
label: const Text('INR'),
hintText: '8000',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(30),
),
),
),
const SizedBox(height: 10),
MaterialButton(
onPressed: () {
usd.clear();
inr.clear();
},
child: const Text('Reset'),
color: Colors.red,
),
],
),
),
);
}
}