Tarmslitaren / FrosthavenAssistant

flutter app
GNU Affero General Public License v3.0
182 stars 45 forks source link

bug(Settings) Don't reset `Server IP Address` field when you hit `done` on the iOS keyboard #226

Closed nicholaskillin closed 2 months ago

nicholaskillin commented 2 months ago

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 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.

Gifs

Before Change After Change
CleanShot 2024-06-24 at 22 32 39 CleanShot 2024-06-25 at 09 06 08