From ad4630e495aa3bb6dc88ab0c68cc477c6d1af9f7 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Wed, 14 May 2025 18:46:39 -0700 Subject: [PATCH] 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. --- lib/main.dart | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index e4e3465..8d00871 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -23,6 +23,12 @@ class MainApp extends StatefulWidget { } class _MainAppState extends State { + final _formKey = GlobalKey(); + 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 { @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 { return MaterialApp( home: Scaffold( body: Center( - child: Column(children: [Text('Weather Today!'), weatherLayout]), + child: Column( + children: [ + Text('Weather Today!'), + form, + Expanded(child: weatherLayout), + ], + ), ), ), );