skip to Main Content

Behavior of modal is always dispose when we close it. How to prevent the modal from dispose? So when i close it then open it again, the condition still same.

2

Answers


  1. Chosen as BEST ANSWER

    I resolve using Page Storage widget. I think it is the simple way and it can save the scroll position of page.


  2. To prevent the modal from being disposed in Flutter, you can manage its state outside of the modal itself. Here are some tips on how to achieve this:

    State Management: Use a state management solution (like Provider, Bloc, or setState) to manage the state of the content inside the modal.

    Preserve State: Store the state of the modal’s content in a variable that exists outside of the modal. This way, the state is preserved even when the modal is closed.

    Pass State to Modal: When opening the modal, pass the preserved state back to it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search