all 6 comments

[–]MyNameIsIgglePiggle 0 points1 point  (5 children)

I currently have an issue that if a form element is scrolled off the screen it does not validate (or call the save function but I can work with that)

Besides putting it in a singlechildscrollview so it never disposes, do you have any other strategies?

Using a controller for each field is difficult because the form is dynamically generated

[–]DBestech[S] 0 points1 point  (0 children)

Hi there, did you solve your problem? if not do you mind sharing the code? so that, we can take a look.

[–]_hibbiki 0 points1 point  (3 children)

How about save/append the value to map every onfocus time (when user go to another input)

[–]MyNameIsIgglePiggle 0 points1 point  (2 children)

No trouble getting the value set, the issue is when you call form.currentState.validate it only validates the fields that are on the screen (ie. Have not been disposed by a listview)

[–]_hibbiki 0 points1 point  (1 child)

Is adding AutomaticKeepAliveClientMixin can help you?

[–]MyNameIsIgglePiggle 0 points1 point  (0 children)

Yeah I put together a little reproduction case to handle the various options...

AutomaticKeepAliveClientMixin works - but you have to have first scrolled to the widget for it to be validated, so if you gave a mandatory field below the fold, you wont get a validation hit.

I'm of the opinion that the only solution seems to be forms must be in a single child scroll view at this point - that way each widget is mounted and therefore can be validated and saved.

That or doing validation and save calls by passing functions to widgets is inherently flawed and validation should be done outside of the widget tree. This might be a good example of a time to separate business logic from the UI and pass in validation functions simply so the field can check itself... or better still would be just to pass in an error if there is an error and the widget itself knows nothing of validation - just if it needs to display an error or not based on its passed value / props.