Wales77
Wales77

Reputation: 57

Flutter responsive design

So I am working on a Responsive Flutter layout, I figured that once I display different layouts for the respective design sizes, my stateful widgets do not retain states. For example in the login page when a user has filled In a Username and password and he/she resizes from Desktop to mobile/Tablet size, the inputed information are lost, that is for the redisplay of layout the state is not preserved so the login screen on the mobile does not retain the password and username typed in the desktop mode, Please how do I go about this?

Upvotes: 1

Views: 461

Answers (1)

Pieter van Loon
Pieter van Loon

Reputation: 5648

You have a few options:

  • Store the TextEditingController you’re using (and/or any other data) above the widget that switches the layout.
  • Use a GlobalKey such that when changing layouts flutter can match the widgets back up and maintain their state

Upvotes: 3

Related Questions