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

[ISSUE] Unhandled Exception: This widget has been unmounted, so the State no longer has a context (and should be considered defunct). #57

Open
ghost opened this issue Dec 14, 2021 · 5 comments

Comments

@ghost
Copy link

ghost commented Dec 14, 2021

When closing page with CropEditor there is error in the console.

It happens in the method _resetCroppingArea when getting screenSize from context:

void _resetCroppingArea() {
    final screenSize = MediaQuery.of(context).size;

    final imageRatio = _targetImage!.width / _targetImage!.height;
    _isFitVertically = imageRatio < screenSize.aspectRatio;

    _imageRect = calculator.imageRect(screenSize, imageRatio);

    _resizeWith(widget.aspectRatio, widget.initialArea);
  }

image

@ShineYang
Copy link

Same issue.

@chooyan-eng
Copy link
Owner

@PTLam25 @ShineYang
Hi, thank you for the issue.

I guess _CropEditor needs proper dispose() method.

Wait for update or I'll appreciate your pull requests if you have an idea to solve this.

@ChristophKe
Copy link

Same Problem here...

@nyqvistatwork
Copy link

nyqvistatwork commented Oct 20, 2022

Still a problem. EDIT: You can hide the error with:
image

@NikoBoerger
Copy link

I'm having the same issue in my WidgetTests, where this Widget is shown on one of my app pages:

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞══
The following assertion was thrown running a test (but after the test had completed):
This widget has been unmounted, so the State no longer has a context (and should be considered
defunct).
Consider canceling any active work during "dispose" or using the "mounted" getter to determine if
the State is still active.

When the exception was thrown, this was the stack:
#0 State.context. (package:flutter/src/widgets/framework.dart:951:9)
#1 State.context (package:flutter/src/widgets/framework.dart:957:6)
#2 _CropEditorState._resetCroppingArea (package:crop_your_image/src/crop.dart:369:38)
#3 _CropEditorState.didChangeDependencies. (package:crop_your_image/src/crop.dart:339:9

Would appreciate an update. Thanks so much :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants