File 3
File 3
runApp(MyApp());
}
void calculateSplitAmount() {
setState(() {
double? totalBill = double.tryParse(billAmountController.text);
int? numberOfPeople = int.tryParse(peopleCountController.text);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Bill Splitter'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextField(
controller: billAmountController,
keyboardType: TextInputType.number,
decoration: InputDecoration(
labelText: 'Enter total bill amount',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
TextField(
controller: peopleCountController,
keyboardType: TextInputType.number,
decoration: InputDecoration(
labelText: 'Enter number of people',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
ElevatedButton(
onPressed: calculateSplitAmount,
child: Text('Calculate Split Amount'),
),
SizedBox(height: 16),
Text(
splitAmountMessage,
style: TextStyle(fontSize: 18),
),
],
),
),
);
}
}