Attempting to add the form for passing the weather location but it's been failing to render. Hardcoded field sizes for now. Still figuring out how the expense tracker app is working without this.

This commit is contained in:
Hyperling 2025-05-14 18:46:39 -07:00
parent 2ee8eaecc8
commit ad4630e495

View File

@ -23,6 +23,12 @@ class MainApp extends StatefulWidget {
}
class _MainAppState extends State<MainApp> {
final _formKey = GlobalKey<FormState>();
String _zipcode = "";
String _city = "";
String _country = "";
String _latlong = "";
String weather = loadText;
bool keepLoading = false;
DateTime lastLoadTime = DateTime.now().subtract(
@ -42,6 +48,80 @@ class _MainAppState extends State<MainApp> {
@override
Widget build(BuildContext context) {
Widget form = Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
height: 20,
width: 100,
child: TextFormField(
initialValue: _zipcode,
validator: (value) {
return null;
},
onSaved: (value) {
_zipcode = value!;
},
),
),
SizedBox(
height: 20,
width: 100,
child: TextFormField(
initialValue: _city,
validator: (value) {
return null;
},
onSaved: (value) {
_city = value!;
},
),
),
SizedBox(
height: 20,
width: 100,
child: TextFormField(
initialValue: _country,
validator: (value) {
return null;
},
onSaved: (value) {
_country = value!;
},
),
),
],
),
SizedBox(
height: 20,
width: 300,
child: TextFormField(
initialValue: _latlong,
validator: (value) {
return null;
},
onSaved: (value) {
_latlong = value!;
},
),
),
TextButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
}
},
child: Text("Save"),
),
],
),
);
Widget weatherLayout = Column(
children: [Text(weather), CircularProgressIndicator()],
);
@ -71,7 +151,13 @@ class _MainAppState extends State<MainApp> {
return MaterialApp(
home: Scaffold(
body: Center(
child: Column(children: [Text('Weather Today!'), weatherLayout]),
child: Column(
children: [
Text('Weather Today!'),
form,
Expanded(child: weatherLayout),
],
),
),
),
);