Codelessly / ResponsiveFramework

Easily make Flutter apps responsive. Automatically adapt UI to different screen sizes. Responsiveness made simple. Demo: https://gallery.codelessly.com/flutterwebsites/minimal/
https://codelessly.com
MIT License
1.25k stars 150 forks source link

Stateful widget state losing issue fix. #168

Closed Ninja260 closed 6 months ago

Ninja260 commented 7 months ago

Hello bro @rayliverified, I am waiting follow up from you for my pull request. I am having state losing issue because of layout change while I am using the library. This is why this pull request happens. I will be waiting for you reply.

rayliverified commented 7 months ago

KK, taking a look.

Thank you for raising this issue.

rayliverified commented 7 months ago

I don't understand what Flex solves here. Can you help me understand?

Ninja260 commented 6 months ago

@rayliverified If we put a StatefulWidget under a ResponsiveRowColumn widget, the stateful widget loses state when the ResponsiveRowColumn layout change from Row to Column, and vice versa. This is because the inner widget tree of the ResponsiveRowColumn changes when Row or Column is being conditionally rendered.

To Solve this issue, I proposed to use Flex in place of using Row and Column. Flex have the same constructor arguments as Row or Column. The only difference is that we need to define the direction argument, which is used to decide whether to render as Row or Column.

In that way, the inner widget tree of the ResponsiveRowColumn will remain intact even the layout changes. The state losing issue is prevented.

Ninja260 commented 6 months ago

bro @rayliverified . I am waiting response from you. :)

rayliverified commented 6 months ago

Will merge today, thank you.

On Fri, 23 Feb 2024, 1:21 am Ninja260, @.***> wrote:

bro @rayliverified https://github.com/rayliverified . I am waiting response from you. :)

— Reply to this email directly, view it on GitHub https://github.com/Codelessly/ResponsiveFramework/pull/168#issuecomment-1960840050, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEXZO3R45MQKJNYPEZNQENDYVA7ORAVCNFSM6AAAAABCKHYPUSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRQHA2DAMBVGA . You are receiving this because you were mentioned.Message ID: @.***>