Notes
Notes - notes.io |
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Kindacode.com',
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
// the controller for the text field associated with "height"
final _heightController = TextEditingController();
// the controller for the text field associated with "weight"
final _weightController = TextEditingController();
// The BMI
double? _bmi;
// the message at the beginning
String _message = 'Биеийн жин болон өндөрөө оруулна уу!!';
void _calculate() {
final double? height = double.tryParse(_heightController.value.text);
final double? weight = double.tryParse(_weightController.value.text);
// Check if the inputs are valid
if (height == null || height <= 0 || weight == null || weight <= 0) {
setState(() {
_message = "Your height and weigh must be positive numbers";
});
return;
}
setState(() {
_bmi = weight / (height * height);
if (_bmi! < 18.5) {
_message = "Туранхай";
} else if (_bmi! < 25) {
_message = 'Хэвийн жин';
} else if (_bmi! < 30) {
_message = 'Таргалалттай';
} else {
_message = 'Хэт таргалалттай';
}
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color.fromARGB(255, 154, 189, 221),
body: Center(
child: Container(
width: 320,
child: Card(
color: Colors.white,
elevation: 10,
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextField(
keyboardType:
TextInputType.numberWithOptions(decimal: true),
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'жишээ:180',
labelText: 'Өндөр (m)'),
controller: _heightController,
),
TextField(
keyboardType:
TextInputType.numberWithOptions(decimal: true),
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'жишээ: 60',
labelText: 'Жин (kg)',
),
controller: _weightController,
),
ElevatedButton(
onPressed: _calculate,
child: Text('Тооцоолох'),
),
SizedBox(
height: 30,
),
Container(
child: Text(
_bmi == null
? 'Утга оруулаагүй'
: _bmi!.toStringAsFixed(2),
style: TextStyle(fontSize: 25),
textAlign: TextAlign.center,
),
),
SizedBox(
height: 20,
),
Container(
child: Text(
_message,
textAlign: TextAlign.center,
),
)
],
),
),
),
),
));
}
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team
