101 lines
3.0 KiB
Dart
101 lines
3.0 KiB
Dart
// Helpful guides:
|
|
// - https://flutter.dev/docs/cookbook/forms/validation
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
void main() {
|
|
runApp(const MainApp());
|
|
}
|
|
|
|
class MainApp extends StatefulWidget {
|
|
const MainApp({super.key});
|
|
|
|
@override
|
|
State<MainApp> createState() => _MainAppState();
|
|
}
|
|
|
|
class _MainAppState extends State<MainApp> {
|
|
final nameFieldController = TextEditingController();
|
|
|
|
@override
|
|
void dispose() {
|
|
// Clean up the controller when the widget is disposed.
|
|
nameFieldController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
const inputWidth = 400.0;
|
|
const inputHeight = 50.0;
|
|
|
|
const recurrenceValues = <DropdownMenuEntry>[
|
|
DropdownMenuEntry(value: Recurrence.daily, label: "Daily"),
|
|
DropdownMenuEntry(value: Recurrence.weekly, label: "Weekly"),
|
|
DropdownMenuEntry(value: Recurrence.biweekly, label: "Biweekly"),
|
|
DropdownMenuEntry(value: Recurrence.montly, label: "Monthly"),
|
|
DropdownMenuEntry(value: Recurrence.yearly, label: "Yearly"),
|
|
];
|
|
|
|
return const MaterialApp(
|
|
home: Scaffold(
|
|
body: Center(
|
|
child: Column(mainAxisSize: MainAxisSize.min, spacing: 10, children: [
|
|
Text('Input an expense below!'),
|
|
SizedBox(
|
|
width: inputWidth,
|
|
height: inputHeight,
|
|
child: TextField(
|
|
keyboardType: TextInputType.text,
|
|
decoration: InputDecoration(
|
|
labelText: "Name",
|
|
hintText: "Example: Red Pocket Phone Bill",
|
|
),
|
|
// https://docs.flutter.dev/cookbook/forms/retrieve-input
|
|
//controller: nameFieldController,
|
|
)),
|
|
SizedBox(
|
|
width: inputWidth,
|
|
height: inputHeight,
|
|
child: TextField(
|
|
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
|
decoration: InputDecoration(
|
|
labelText: "Cost", hintText: "Example: 10.00"),
|
|
),
|
|
),
|
|
DropdownMenu(
|
|
dropdownMenuEntries: recurrenceValues,
|
|
width: inputWidth,
|
|
label: Text("Recurrence"),
|
|
hintText: "Example: Monthly",
|
|
),
|
|
SizedBox(
|
|
width: inputWidth,
|
|
height: inputHeight,
|
|
child: TextField(
|
|
keyboardType: TextInputType.text,
|
|
decoration: InputDecoration(
|
|
labelText: "Description",
|
|
hintText:
|
|
"Example: 1GB data with unlimited talk & text."
|
|
),
|
|
)),
|
|
]),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
// https://www.tutorialspoint.com/dart_programming/dart_programming_enumeration.htm
|
|
enum Recurrence { daily, weekly, biweekly, montly, yearly }
|
|
|
|
class Expense {
|
|
String name;
|
|
double cost;
|
|
Recurrence recurrence;
|
|
String description;
|
|
|
|
Expense(this.name, this.cost, this.recurrence, this.description);
|
|
}
|