I'm getting error on building navigationDrawer where tootlip widget needs materialApp as ancestor.
here is what error says :
I/flutter ( 5780): _TooltipState#bc79e(ticker inactive)):
I/flutter ( 5780): No Overlay widget found.
I/flutter ( 5780): Tooltip widgets require an Overlay widget ancestor for correct operation.
I/flutter ( 5780): The most common way to add an Overlay to an application is to include a MaterialApp or Navigator
I/flutter ( 5780): widget in the runApp() call.
I/flutter ( 5780): The specific widget that failed to find an overlay was:
I/flutter ( 5780): Tooltip
I/flutter ( 5780):
I/flutter ( 5780): The relevant error-causing widget was:
I/flutter ( 5780): AppBar
my main.dart code
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
... //basic info title & theme
builder: (context, child) => LayoutTemplate(child: child),
initialRoute:"/home",
... //Routing stuff like generate route & navigator key
);
}
}
LayoutTemplate Widget
class LayoutTemplate extends StatelessWidget {
final Widget child;
const LayoutTemplate({Key key, this.child}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("home"))
drawer: NavDrawer()
body: Column(
children: <Widget>[
//NavigationBar(),
Expanded(
child: child,
)
],
),
);
}
}
sorry for adding too much code. I'm not sure what causing the issue. maybe the builder
from MaterialApp
is causing it.
thank you for helping.
In your builder, just return an Overlay widget with the LayoutTemplate as OverlayEntry.
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
... //basic info title & theme
builder: (context, child) {
return Overlay(
initialEntries: [
OverlayEntry(
builder: (context) => LayoutTemplate(child: child),
),
],
);
},
initialRoute:"/home",
... //Routing stuff like generate route & navigator key
);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With