ponnamkarthik/FlutterToast

[Exception on v8.2.8] No Directionality widget found.

Closed this issue · 2 comments

When I run my existing project with fluttertoast 8.2.8, an exception is occurred below. (Flutter 3.19.0 / Dart 3.3.0)
Could you please check this issue?

======== Exception caught by widgets library =======================================================
The following assertion was thrown building Overlay(state: OverlayState#b3362(entries: [OverlayEntry#b593b(opaque: false; maintainState: false)])):
No Directionality widget found.

_Theater widgets require a Directionality widget ancestor.

The specific widget that could not find a Directionality ancestor was: _Theater
skipCount: 0
dirty

Typically, the Directionality widget is introduced by the MaterialApp or WidgetsApp widget at the top of your application widget tree. It determines the ambient reading direction and is used, for example, to determine how to lay out text, how to interpret "start" and "end" values, and to resolve EdgeInsetsDirectional, AlignmentDirectional, and other *Directional objects.

The relevant error-causing widget was:
Overlay Overlay:file:///Users/tyler.jeong/.pub-cache/hosted/pub.dev/fluttertoast-8.2.8/lib/fluttertoast.dart:325:12

Could you please provide a sample example to check this? I believe the issue might be that the key you're passing is above the MaterialApp in the widget tree.

I have fixed it by changing MaterialApp() and FToastBuilder() order.

[Error]
FToastBuilder() -> MaterialApp()

[Solved]
MaterialApp() -> FToastBuilder()

Thanks!