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

Fix widget state interaction after dispose #193

Merged
merged 1 commit into from
Aug 18, 2021

Conversation

davidmartos96
Copy link
Contributor

Hello!
After updating to v4.2 from v3.x I have encountered some errors logs in the Sentry dashboard of a production app coming from the package. Here are some examples:

_CastError: Null check operator used on a null value
  libapp              0x6d72af1b14 _SpeedDialState.toggleOverlay.<T> (package:flutter_speed_dial/src/speed_dial.dart:341)
  libapp              0x6d72b7653c _OverlayEntryWidgetState.build (package:flutter/src/widgets/overlay.dart:208)
  libapp              0x6d72db90a4 StatefulElement.build (package:flutter/src/widgets/framework.dart:4691)
  libapp              0x6d72a16c4c ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4574)
_CastError: Null check operator used on a null value
  libapp              0x7714decfd4 BackgroundOverlay.build (package:flutter_speed_dial/src/background_overlay.dart:45)
  libapp              0x7714ba9334 _AnimatedState.build (package:flutter/src/widgets/transitions.dart:174)
  libapp              0x7714de90a4 StatefulElement.build (package:flutter/src/widgets/framework.dart:4691)
  libapp              0x7714a46c4c ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4574)
_CastError: Null check operator used on a null value
  libapp              0x717fb28ad8 AnimationController.stop (package:flutter/src/animation/animation_controller.dart:777)
  libapp              0x717fb297b8 AnimationController._animateToInternal (package:flutter/src/animation/animation_controller.dart:597)
  libapp              0x717fb29520 AnimationController.reverse (package:flutter/src/animation/animation_controller.dart:495)
  libapp              0x717fe2df4c _SpeedDialState.toggleOverlay (package:flutter_speed_dial/src/speed_dial.dart:301)
  libapp              0x717fe2de9c _SpeedDialState._toggleChildren (package:flutter_speed_dial/src/speed_dial.dart:230)
  libapp              0x717fb4676c GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182)
  libapp              0x71801e8d00 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:607)

All three seem to indicate that the widget is doing setState or similar after it has been disposed, so I've included an is mounted check.

I've also updated the openCloseDial listener disposal by pointing to the same function. I that the following doesn't work
widget.openCloseDial?.removeListener(() {});
It would simply remove a listener that has never been saved in the first place.

@prateekmedia prateekmedia merged commit fc13ff2 into darioielardi:master Aug 18, 2021
@prateekmedia
Copy link
Collaborator

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants