cmdrootaccess / another-flushbar

A flexible widget for user notification. Customize your text, button, duration, animations and much more. For Android devs, it is made to replace Snackbars and Toasts.
https://pub.dev/packages/another_flushbar
MIT License
146 stars 90 forks source link

Application throws error #59

Closed haslinger closed 1 year ago

haslinger commented 2 years ago

I believe, this happens, when a flushbar is dismissed, but I don't know for sure, because there is no line from my app code in the stack, so I'm actually a bit confused, what I could do to debug this:

======== Exception caught by foundation library ====================================================
The following _TypeError was thrown while dispatching notifications for OverlayEntry:
type 'Null' is not a subtype of type 'Object'

When the exception was thrown, this was the stack: 
#1      FlushbarRoute.dispose (package:another_flushbar/flushbar_route.dart:438:26)
#2      _RouteEntry.dispose.<anonymous closure> (package:flutter/src/widgets/navigator.dart:3001:19)
#3      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:308:24)
#4      OverlayEntry._updateMounted (package:flutter/src/widgets/overlay.dart:130:5)
#5      _OverlayEntryWidgetState.dispose (package:flutter/src/widgets/overlay.dart:200:18)
#6      StatefulElement.unmount (package:flutter/src/widgets/framework.dart:4983:11)
#7      _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1926:13)
#8      ListIterable.forEach (dart:_internal/iterable.dart:39:13)
#9      _InactiveElements._unmountAll (package:flutter/src/widgets/framework.dart:1935:25)
#10     BuildOwner.lockState (package:flutter/src/widgets/framework.dart:2519:15)
#11     BuildOwner.finalizeTree (package:flutter/src/widgets/framework.dart:2932:7)
#12     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:884:19)
#13     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:363:5)
#14     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
#15     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1081:9)
#16     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:995:5)
#20     _invoke (dart:ui/hooks.dart:151:10)
#21     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:308:5)
#22     _drawFrame (dart:ui/hooks.dart:115:31)
(elided 4 frames from dart:async)
The OverlayEntry sending notification was: OverlayEntry#a3e2b(opaque: false; maintainState: false)
====================================================================================================

I switched to another-flushbar to when I switched my code to null safety. My environment is:

Flutter 2.10.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision db747aa133 (3 weeks ago) • 2022-02-09 13:57:35 -0600
Engine • revision ab46186b24
Tools • Dart 2.16.1 • DevTools 2.9.2

Any help in debugging this is highly welcome. Not expecting anyone to actually look into my app, but just for reference, it is Encrateia and the state I'm talking about is in the upgrade-2021-project branch.

elkhalifte commented 2 years ago

this is actually happening if your app calls flushbar from background.

to fix the issue add your flushbar code inside

WidgetsBinding.instance.addPostFrameCallback((_) {
// flushbar...
});