Advertisement
thinkdigital

BMI Calculator

May 19th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 2.28 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. class Home extends StatefulWidget {
  4.   @override
  5.   State<StatefulWidget> createState() {
  6.     return new HomeState();
  7.   }
  8. }
  9.  
  10. class HomeState extends State<Home> {
  11.   @override
  12.   Widget build(BuildContext context) {
  13.     final TextEditingController _ageController = new TextEditingController();
  14.     final TextEditingController _heightController = new TextEditingController();
  15.     final TextEditingController _weightController = new TextEditingController();
  16.  
  17.     return new Scaffold(
  18.       appBar: new AppBar(
  19.         title: new Text('BMI'),
  20.         centerTitle: true,
  21.         backgroundColor: Colors.pinkAccent,
  22.       ),
  23.       body: new Column(
  24.         children: <Widget>[
  25.           new Center(
  26.             child: new Image.asset("images/bmilogo.png"),
  27.           ),
  28.           new Padding(padding: new EdgeInsets.all(18.0)),
  29.           new Container(
  30.             color: Colors.grey.shade300,
  31.             padding: new EdgeInsets.all(15.0),
  32.             child: new Column(
  33.               children: <Widget>[
  34.                 new TextField(
  35.                   controller: _ageController,
  36.                   decoration: new InputDecoration(
  37.                       icon: new Icon(Icons.person_outline), labelText: "Age"),
  38.                 ),
  39.                 new TextField(
  40.                   controller: _heightController,
  41.                   decoration: new InputDecoration(
  42.                       icon: new Icon(Icons.insert_chart),
  43.                       labelText: "Height (in feet)"),
  44.                 ),
  45.                 new TextField(
  46.                   controller: _weightController,
  47.                   decoration: new InputDecoration(
  48.                       icon: new Icon(Icons.line_weight),
  49.                       labelText: "Weight (in lbs)"),
  50.                 ),
  51.                 new Padding(padding: new EdgeInsets.only(top: 20.0)),
  52.                 new RaisedButton(
  53.                   onPressed: calculate(1, 2),
  54.                   color: Colors.pinkAccent,
  55.                   child: new Text(
  56.                     "Calculate",
  57.                     style: new TextStyle(color: Colors.white),
  58.                   ),
  59.                 )
  60.               ],
  61.             ),
  62.           ),
  63.  
  64.         ],
  65.       ),
  66.     );
  67.   }
  68.  
  69.   void calculate(num1, num2) {
  70.  
  71.   }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement