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.
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
I resolve using Page Storage widget. I think it is the simple way and it can save the scroll position of page.
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.