Search code examples
androidflutterflutter-layoutviewmodel

How does Flutter maintain consistency without loosing its data on any orientation change?


I have been coding into flutter and is wondering if there is any kind of ViewModel thing that is supported in Flutter. Main purpose of VieModel (as per the use in Android) is to separate the Views from the data. Also, in Android, if we are filling a form then, on the change of orientation, the data of the several columns is not loss(due to ViewModel), how can we achieve the same in Flutter.

PS: I have been using Flutter's Form widget with FormTextField, it maintains it's sate (my Question is how? & why?) Also, I have blank data when I come back to my Form with Navigator.pop() , why ? Do I have to make some changeNotifier or ViewModel to sync up things? How to Pre-fill my Form with model instance.


Solution

  • Flutter doesn't lose its data because it uses its own render engine (aka skia) normal flutter app has just one activity with 'Canvas' that render everything and because of that it gives flutter opportunity to save the state of all UI (because it's not native views just all widgets renders via canvas)