Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

widget unmounted error with multiple swipers in listView #24

Closed
mpiparo opened this issue Jan 3, 2022 · 4 comments
Closed

widget unmounted error with multiple swipers in listView #24

mpiparo opened this issue Jan 3, 2022 · 4 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@mpiparo
Copy link

mpiparo commented Jan 3, 2022

observed with card_swiper v1.0.4

running into an issue where I have a listView of swipers, they are appropriately unmounted as they go out of scrollview, however if I reverse scroll back (with a previous swiper coming back into view), I occasionally get the following error:

"This widget has been unmounted, so the State no longer has a context (and should be considered defunct)."

it looks like it is triggered when the TransformerPageView tries to get the renderObject from the context (below), but not sure why it's being called after it's unmounted? possibly a timing issue? open to any suggestions. -- thanks!

void _onGetSize(_) {
    Size? size;

    // if (context == null) {
    //   onGetSize(size);
    //   return;
    // }
    final renderObject = context.findRenderObject();
    if (renderObject != null) {
      final bounds = renderObject.paintBounds;
      size = bounds.size;
    }
    _calcCurrentPixels();
    onGetSize(size);
 }

update: I notice that there is no "if (mounted)" check before the context.findRenderObject() is called, and also am curious why the context == null check has been commented out?

@TheAnkurPanchani TheAnkurPanchani self-assigned this Jan 10, 2022
@TheAnkurPanchani TheAnkurPanchani added bug Something isn't working help wanted Extra attention is needed labels Jan 10, 2022
@Not-Dhanraj
Copy link

yup, i am facing same issue right now

@mpiparo
Copy link
Author

mpiparo commented Feb 5, 2022

checked on latest v2.0.1, still an issue. I'm ok with simply commenting back in the null check for the context, but I'd be a little concerned since it was purposely commented out as some point, so not sure of the repercussions?

@MinByeongDon
Copy link

I am facing same issue too at 2.0.1

@Not-Dhanraj
Copy link

Not-Dhanraj commented Mar 10, 2022

I was using a CustomScrollView so instead of using SliverToBoxAdapter i shifted to SliverPersistentHeader and then issue was gone.
I hope it helps others as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants