Break the form into its own widget, since eventually it'll likely be a pop-up.
This commit is contained in:
parent
45b5e33491
commit
aaa95bd3a6
@ -2,28 +2,42 @@
|
|||||||
// - https://flutter.dev/docs/cookbook/forms/validation
|
// - https://flutter.dev/docs/cookbook/forms/validation
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
//import 'package:provider/provider.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MainApp());
|
runApp(const MainApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
class MainApp extends StatefulWidget {
|
class MainApp extends StatelessWidget {
|
||||||
const MainApp({super.key});
|
const MainApp({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<MainApp> createState() => _MainAppState();
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
|
return MaterialApp(
|
||||||
|
title: 'Recurring Expense Tracker',
|
||||||
|
theme: ThemeData(
|
||||||
|
useMaterial3: true,
|
||||||
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.green),
|
||||||
|
),
|
||||||
|
home: Scaffold(
|
||||||
|
body: ExpenseInputForm(),
|
||||||
|
//floatingActionButton: IconButton(onPressed: appState.newExpense(), icon: Icon(Icons.add)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MainAppState extends State<MainApp> {
|
class ExpenseInputForm extends StatefulWidget {
|
||||||
final nameFieldController = TextEditingController();
|
const ExpenseInputForm({
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
State<ExpenseInputForm> createState() => _ExpenseInputFormState();
|
||||||
// Clean up the controller when the widget is disposed.
|
|
||||||
nameFieldController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _ExpenseInputFormState extends State<ExpenseInputForm> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
const inputWidth = 400.0;
|
const inputWidth = 400.0;
|
||||||
@ -37,9 +51,7 @@ class _MainAppState extends State<MainApp> {
|
|||||||
DropdownMenuEntry(value: Recurrence.yearly, label: "Yearly"),
|
DropdownMenuEntry(value: Recurrence.yearly, label: "Yearly"),
|
||||||
];
|
];
|
||||||
|
|
||||||
return const MaterialApp(
|
return Center(
|
||||||
home: Scaffold(
|
|
||||||
body: Center(
|
|
||||||
child: Column(mainAxisSize: MainAxisSize.min, spacing: 10, children: [
|
child: Column(mainAxisSize: MainAxisSize.min, spacing: 10, children: [
|
||||||
Text('Input an expense below!'),
|
Text('Input an expense below!'),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@ -81,8 +93,6 @@ class _MainAppState extends State<MainApp> {
|
|||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
]),
|
]),
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user