This addresses a minor bug I discovered when editing the server IP address in settings on an iOS device.
Currently, if you hit done on the iOS keyboard after updating the value for the text field, the value of the text field resets back to the lastKnownConnection value (gif below).
How does it fix it?
Apparently hitting done on the iOS keyboard causes the widget to rebuild. We were setting the value for the server IP address text field and the port fields during the build process.
After some digging it sounds like it is actually best practice to set those default values in initState. This ensures that we set the default values once and not every time the widget rebuilds.
Notes
This also cleans up one very minor whitespace issue in a for loop and moves the final variables for this widget around a bit to make sure that they are available to initState and still all located in the same place.
What does this do?
This addresses a minor bug I discovered when editing the server IP address in settings on an iOS device.
Currently, if you hit
done
on the iOS keyboard after updating the value for the text field, the value of the text field resets back to thelastKnownConnection
value (gif below).How does it fix it?
Apparently hitting
done
on the iOS keyboard causes the widget to rebuild. We were setting the value for the server IP address text field and the port fields during the build process.After some digging it sounds like it is actually best practice to set those default values in
initState
. This ensures that we set the default values once and not every time the widget rebuilds.Notes
This also cleans up one very minor whitespace issue in a for loop and moves the final variables for this widget around a bit to make sure that they are available to
initState
and still all located in the same place.Gifs