FilledStacks / flutter-tutorials

The repo contains the source code for all the tutorials on the FilledStacks Youtube channel.
MIT License
4.75k stars 1.76k forks source link

014 - Provider #70

Closed MobileMon closed 4 years ago

MobileMon commented 4 years ago

General architecture question

Should the LoginViewModel contain the TextEditingController instead of having a stateful widget do so in the login_view?

That way you could manage all of the view's state right from within the ViewModel instead of having a separate state manager

FilledStacks commented 4 years ago

sup @MobileMon No. The reason we have the separate files is to have a clear separation between business logic / state and UI. Textedtitng is 100% UI related and should not be in the viewmodel. No ui things should be in the viewmodel, it has to be pure enough to test without Starting up flutter when writing unit tests.

You can use FlutterHooks if you don't want to use a stateful widget which is what I do.

MobileMon commented 4 years ago

Thanks @FilledStacks

Keep up the good work! Your tutorials are awesome and are very helpful!