Overlay.of(Get.overlayContext) fails after Flutter 3.38.1
The code in the example used to work fine for previous Flutter versions. With 3.38.1 it throws an Exception. I created an issue in flutter repo https://github.com/flutter/flutter/issues/178600, because there are no breaking changes informed related to this. However, this could be related to the way Get package mantains and retrieves the rootOverlay.
FlutterError (No Overlay widget found.
Some widgets require an Overlay widget ancestor for correct operation.
The most common way to add an Overlay to an application is to include a MaterialApp, CupertinoApp or Navigator widget in the runApp() call.
The context from which that widget was searching for an overlay was:
Overlay-[LabeledGlobalKey<OverlayState>#212d7])
example:
import 'package:flutter/material.dart';
import 'package:get/route_manager.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return GetMaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
void _showBubble() {
Bubble.show('This is a Bubble', duracion: 3);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(onPressed: _showBubble, child: Text('Show Bubble')),
],
),
),
);
}
}
class Bubble {
static OverlayEntry? overlayEntry;
static void show(
String text, {
int duracion = 4,
Color? backColor,
Color? textColor,
AlignmentGeometry alignment = Alignment.center,
}) {
if (overlayEntry != null) {
Bubble.hide();
}
overlayEntry = OverlayEntry(
builder: (context) => WidgetBubble(
text: text,
backColor: backColor,
textColor: textColor,
alignment: alignment,
),
);
final overlay = Overlay.of(Get.overlayContext!);
overlay.insert(overlayEntry!);
// Wait for 2 seconds
Future.delayed(Duration(seconds: duracion)).then((value) {
Bubble.hide();
});
}
static void error(String text, {int duracion = 4}) {
Bubble.show(
text,
duracion: duracion,
backColor: Colors.red,
textColor: Colors.white,
);
}
static void hide() {
if (overlayEntry != null) {
overlayEntry!.remove();
overlayEntry = null;
}
}
}
class WidgetBubble extends StatelessWidget {
const WidgetBubble({
required this.text,
super.key,
this.backColor,
this.textColor,
this.alignment = Alignment.center,
});
final String text;
final Color? backColor;
final Color? textColor;
final AlignmentGeometry alignment;
@override
Widget build(BuildContext context) {
return SafeArea(
child: Align(
alignment: alignment,
child: Dismissible(
key: Key('bubble_${DateTime.now().millisecondsSinceEpoch}'),
onDismissed: (_) => Bubble.hide(),
child: Card(
elevation: 20,
shadowColor: Colors.black,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
borderOnForeground: false,
color: Colors.yellow,
child: SizedBox(
width: 200,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 20),
child: Text(text, textAlign: TextAlign.center),
),
),
),
),
),
);
}
}
To Reproduce Run the provided code, and tap the button. You can test with v3.35.7 and v3.38.1 to compare the results.
Expected behavior No exception
Flutter Version: 3.38.1
Getx Version: 4.7.2
Describe on which device you found the bug: IOS, Android, macos
Minimal reproduce code Code above
i have the same problem
Not sure that this worth separate ticket, posting here as also concerns snackbars overlays – which seems got severely broken in 3.38.x.
Android:
Null check operator used on a null value
0 Overlay.of (package:flutter/src/widgets/overlay.dart:592)
1 SnackbarController._configureOverlay (package:get/get_navigation/src/snackbar/snackbar_controller.dart:91)
2 SnackbarController._show (package:get/get_navigation/src/snackbar/snackbar_controller.dart:331)
3 GetQueue._check (package:get/get_utils/src/queue/get_queue.dart:42)
4 GetQueue.add (package:get/get_utils/src/queue/get_queue.dart:29)
5 _SnackBarQueue._addJob (package:get/get_navigation/src/snackbar/snackbar_controller.dart:357)
6 SnackbarController.show (package:get/get_navigation/src/snackbar/snackbar_controller.dart:63)
7 ExtensionSnackbar.showSnackbar (package:get/get_navigation/src/extension_navigation.dart:366)
8 GetSnackBar.show (package:get/get_navigation/src/snackbar/snackbar.dart:290)
9 SnackbarService.showCustomSnackBar.<anonymous closure> (package:stacked_services/src/snackbar/snackbar_service.dart:248)
Web:
Null check operator used on a null value
../../../../../../flutter/packages/flutter/lib/src/widgets/overlay.dart 592:18 SnackbarController._configureOverlay
dart://_internal/js_runtime/lib/js_helper.dart 2635:9 Closure.cspForwardCall
../../../../../../.pub-cache/hosted/pub.dev/get-4.7.2/lib/get_utils/src/queue/get_queue.dart 42:39 GetQueue._check
dart://_internal/js_runtime/lib/async_patch.dart 339:19 _wrapJsFunctionForAsync
dart://_internal/js_runtime/lib/async_patch.dart 365:23 _wrapJsFunctionForAsync.
dart://_internal/js_runtime/lib/async_patch.dart 265:3 _asyncStartSync
../../../../../../.pub-cache/hosted/pub.dev/get-4.7.2/lib/get_utils/src/queue/get_queue.dart 38:5 GetQueue._check
../../../../../../.pub-cache/hosted/pub.dev/get-4.7.2/lib/get_utils/src/queue/get_queue.dart 29:5 _SnackBarQueue._addJob
dart://_internal/js_runtime/lib/async_patch.dart 339:19 _wrapJsFunctionForAsync
dart://_internal/js_runtime/lib/async_patch.dart 365:23 _wrapJsFunctionForAsync.
dart://_internal/js_runtime/lib/async_patch.dart 265:3 _asyncStartSync
../../../../../../.pub-cache/hosted/pub.dev/get-4.7.2/lib/get_navigation/src/snackbar/snackbar_controller.dart 356:19 _SnackBarQueue._addJob
../../../../../../.pub-cache/hosted/pub.dev/get-4.7.2/lib/get_navigation/src/snackbar/snackbar_controller.dart 356:19 _SnackBarQueue._addJob
../../../../../../.pub-cache/hosted/pub.dev/get-4.7.2/lib/get_navigation/src/snackbar/snackbar_controller.dart 63:27 ExtensionSnackbar.showSnackbar
dart://_internal/js_runtime/lib/async_patch.dart 339:19 _wrapJsFunctionForAsync
dart://_internal/js_runtime/lib/async_patch.dart 365:23 _wrapJsFunctionForAsync.
dart://_internal/js_runtime/lib/async_patch.dart 265:3 _asyncStartSync
../../../../../../.pub-cache/hosted/pub.dev/stacked_services-1.6.0/lib/src/snackbar/snackbar_service.dart 248:15 SnackbarService_showCustomSnackBar_closure
../../../../../../.pub-cache/hosted/pub.dev/stacked_services-1.6.0/lib/src/snackbar/snackbar_service.dart 248:15 SnackbarService.showCustomSnackBar.
../../../../../../flutter/packages/flutter/lib/src/scheduler/binding.dart 1434:7 SchedulerBinding._invokeFrameCallback
../../../../../../flutter/packages/flutter/lib/src/scheduler/binding.dart 1423:8 SchedulerBinding._invokeFrameCallback[function-entry$2]
../../../../../../flutter/packages/flutter/lib/src/scheduler/binding.dart 1361:11 SchedulerBinding.handleDrawFrame
../../../../../../flutter/packages/flutter/lib/src/scheduler/binding.dart 1200:5 SchedulerBinding._handleDrawFrame
dart://_internal/js_runtime/lib/js_helper.dart 2635:9 Closure.cspForwardCall
org-dartlang-sdk:///lib/_engine/engine/platform_dispatcher.dart 1538:5 invoke
org-dartlang-sdk:///lib/_engine/engine/platform_dispatcher.dart 265:5 FrameService._renderFrame
dart://async/zone.dart 1546:12 _rootRunUnary
dart://async/zone.dart 1428:34 _CustomZone.runUnary
dart://_internal/js_runtime/lib/js_allow_interop_patch.dart 363:27 _callDartFunctionFast1
Null check operator used on a null value
../../../../../../flutter/packages/flutter/lib/src/widgets/overlay.dart 592:18 SnackbarController._configureOverlay
dart://_internal/js_runtime/lib/js_helper.dart 2635:9 Closure.cspForwardCall
../../../../../../.pub-cache/hosted/pub.dev/get-4.7.2/lib/get_utils/src/queue/get_queue.dart 42:39 GetQueue._check
dart://_internal/js_runtime/lib/async_patch.dart 339:19 _wrapJsFunctionForAsync
dart://_internal/js_runtime/lib/async_patch.dart 365:23 _wrapJsFunctionForAsync.
dart://_internal/js_runtime/lib/async_patch.dart 265:3 _asyncStartSync
../../../../../../.pub-cache/hosted/pub.dev/get-4.7.2/lib/get_utils/src/queue/get_queue.dart 38:5 GetQueue._check
../../../../../../.pub-cache/hosted/pub.dev/get-4.7.2/lib/get_utils/src/queue/get_queue.dart 29:5 _SnackBarQueue._addJob
dart://_internal/js_runtime/lib/async_patch.dart 339:19 _wrapJsFunctionForAsync
Flutter doctor
[✓] Flutter (Channel stable, 3.38.2, on macOS 15.6.1 24G90 darwin-arm64, locale en-US) [224ms]
• Flutter version 3.38.2 on channel stable at /Users/ilija/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f5a8537f90 (3 days ago), 2025-11-18 09:27:21 -0500
• Engine revision b5990e5ccc
• Dart version 3.10.0
• DevTools version 2.51.1
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets,
omit-legacy-version-file, enable-lldb-debugging
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [977ms]
• Android SDK at /Users/ilija/Library/Android/sdk
• Emulator version 36.2.12.0 (build_id 14214601) (CL:N/A)
• Platform android-36, build-tools 36.0.0
• Java binary at: /opt/homebrew/opt/openjdk@17/bin/java
This JDK is specified in your Flutter configuration.
To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment Homebrew (build 17.0.14+0)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.2) [715ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16C5032a
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [5ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Connected device (2 available) [5.9s]
• macOS (desktop) • macos • darwin-arm64 • macOS 15.6.1 24G90 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 134.0.6998.166
[✓] Network resources [165ms]
• All expected network resources are available.
• No issues found!
[✓] Flutter (Channel stable, 3.38.2, on macOS 15.6.1 24G90 darwin-arm64, locale en-US) [224ms]
• Flutter version 3.38.2 on channel stable at /Users/ilija/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f5a8537f90 (3 days ago), 2025-11-18 09:27:21 -0500
• Engine revision b5990e5ccc
• Dart version 3.10.0
• DevTools version 2.51.1
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets,
omit-legacy-version-file, enable-lldb-debugging
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [977ms]
• Android SDK at /Users/ilija/Library/Android/sdk
• Emulator version 36.2.12.0 (build_id 14214601) (CL:N/A)
• Platform android-36, build-tools 36.0.0
• Java binary at: /opt/homebrew/opt/openjdk@17/bin/java
This JDK is specified in your Flutter configuration.
To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment Homebrew (build 17.0.14+0)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.2) [715ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16C5032a
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [5ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Connected device (2 available) [5.9s]
• macOS (desktop) • macos • darwin-arm64 • macOS 15.6.1 24G90 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 134.0.6998.166
[✓] Network resources [165ms]
• All expected network resources are available.
• No issues found!
Going to try a workaround offered here.
same issue. Get.overlayContext causes the problem.
For workaround see https://github.com/flutter/flutter/issues/178600#issuecomment-3580877721 TL;DR Issue mitigation
// OLD (broken in Flutter 3.38)
Overlay.of(Get.overlayContext!);
// NEW (works with Flutter 3.38+)
Get.overlayContext!
.findAncestorStateOfType<OverlayState>();
For workaround see flutter/flutter#178600 (comment) TL;DR Issue mitigation
// OLD (broken in Flutter 3.38) Overlay.of(Get.overlayContext!);
// NEW (works with Flutter 3.38+) Get.overlayContext! .findAncestorStateOfType<OverlayState>();
it's work, thank you
update to the latest dependency will fix this issue