๐Ÿ“ฑ 8 / 100 Days Of Flutter, Kate's edition โ€” getting started with forms

๐Ÿ“ฑ 8 / 100 Days Of Flutter, Kate's edition โ€” getting started with forms

Hi, Hashnode community and welcome to week 2 of my Flutter challenge! ๐Ÿ‘‹

Today I continued with the free Udacity course. I finally understood how ColorSwatch works and started to build a simple unit converter form.

It involved:

  • Creating a stateful widget
  • Adding a TextField and styling it
  • Adding a DropdownButtonFormField and styling it
  • Updating state in onChanged callbacks

I struggled a bit with state variable types. In the end, I made my state variable nullable as I don't have a default value for it. I'm not sure if it's the right way to do things in Flutter though.

// Not nullable as I can set the default value to an empty string.
String _inputValue = '';
// Nullable as I don't have a default value for a custom Unit type.
Unit? _inputUnit;

Widget of the day - SizedBox

SizedBox is a simple widget that allows creating a box with a specified size.

Today I've used it add some spacing between my two form fields.

Screenshot 2022-05-02 at 22.19.13.png

Summary

On one hand, working with form fields in Flutter is very familiar to React. On the other, it's time consuming to figure out all the new property names and configure my inputs. Tomorrow I will continue with my first Flutter form.

ย