Untitled
unknown
dart
5 years ago
2.7 kB
4
Indexable
import 'package:Bill_Split/widgets/textField_widget.dart'; import 'package:Bill_Split/widgets/text_widget.dart'; import 'package:flutter/material.dart'; class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { final billAmountController = TextEditingController(); final tipController = TextEditingController(); double currentSliderValue = 1; void splitBill(){ double billAmount = double.parse(billAmountController.text); double tip = double.parse(tipController.text); double total = (billAmount + tip); //print(total); print(currentSliderValue); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text( "Bill Split App", ), ), body: Container( padding: EdgeInsets.all(20), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ TextWidget(title: "Bill Amount"), TextFieldWidget( value: this.billAmountController, ), SizedBox( height: 20, ), TextWidget(title: "Tip"), TextFieldWidget( value: this.tipController, ), SizedBox( height: 20, ), TextWidget(title: "Split"), Container( margin: EdgeInsets.symmetric(vertical: 10), child: Column( children: [ Text( currentSliderValue.toString(), style: TextStyle( fontSize: 35, fontWeight: FontWeight.bold, ), ), Slider( value: currentSliderValue, min: 1, max: 10, divisions: 9, onChanged: (double value) { setState(() { currentSliderValue = value; }); }, ), ], ), ), Container( width: double.infinity, child: RaisedButton( onPressed: () { print(billAmountController.text + tipController.text); }, child: Text( "Calculate", ), ), ), ], ), ), ); } }
Editor is loading...