flutter / website

Flutter documentation web site
https://docs.flutter.dev
Other
2.82k stars 3.23k forks source link

'Build a form with validation' page issue #5711

Closed levishai closed 3 years ago

levishai commented 3 years ago

Page URL: https://flutter.dev/docs/cookbook/forms/validation.html Page source: https://github.com/flutter/website/tree/master/src/docs/cookbook/forms/validation.md

Description of issue: In the section "Create a button to validate and submit the form" (and in the interative example) I see this line of code:

if (_formKey.currentState!.validate()) {

I think that the '!' should not be there. I get error in android studio when trying it that way and also can find such operator '!.'...

Do I miss something?

Thanks, Shai

JuYeong0413 commented 3 years ago

If you use Dart SDK lower than 2.12, the code is slightly different - the example is null safe(you can see Null safety at the bottom right corner in the interactive example). See https://dart.dev/null-safety for more information about null safety. :-)

sfshaza2 commented 3 years ago

Yes, @JuYeong0413 is correct. We have been migrating the flutter.dev website to null safety. Closing.