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), + ], + ), ), ), );