import 'package:flutter/material.dart'; import 'package:simple_animations/simple_animations.dart'; import 'FadeAnimation.dart'; import 'ComputePower.dart'; import 'package:flutter/services.dart'; class HomeScreen extends StatefulWidget { @override State createState() => new _State(); } class _State extends State { final myController = TextEditingController(); var bill; @override void initState() { super.initState(); bill = ComputePower.rating(double.parse(myController.text)); } @override void dispose() { super.dispose(); // Clean up the controller when the widget is disposed. myController.dispose(); } Widget build(BuildContext context) { return Scaffold( //appBar: AppBar( // title: Text('Login Screen App'), //), body: Padding( padding: EdgeInsets.all(30), child: ListView( children: [ FadeAnimation(1.1, new Container( alignment: Alignment.center, padding: EdgeInsets.all(20), child: Text( (bill.toString()), style: TextStyle( color: Colors.blue, fontWeight: FontWeight.w500, fontSize: 30), ), ), ), FadeAnimation(1.3, new Container( alignment: Alignment.center, padding: EdgeInsets.only(top: 350.0), child: Text( 'EDLBill', style: TextStyle( color: Colors.blue, fontWeight: FontWeight.w500, fontSize: 30), ), ), ), SizedBox(height: 5), FadeAnimation(1.6, Container( padding: EdgeInsets.all(10), child: TextFormField( controller: myController, decoration: InputDecoration( border: OutlineInputBorder( borderRadius: BorderRadius.circular(25.0), borderSide: BorderSide(),), labelText: 'Enter KWH Usage', hintText: "Your KWH usage?", ), validator: (val) { if (val.length == 0) { return "Please enter your KWH Usage"; } else { return null; } }, keyboardType: TextInputType.number, ), ), ), FadeAnimation(1.9, Container( child: Center( //height: 50, //padding: EdgeInsets.fromLTRB(10, 0, 10, 0), child: RaisedButton( textColor: Colors.white, color: Colors.blue, child: Text('Print Bill'), onPressed: () { //print(myController.text); //var consumption = myController.text; print(bill.toString()); bill; }, ), ), ), ), ], ), ), ); } }