of static method
- BuildContext context
Returns the closest instance of this class's data value that encloses the given context. If there is no ancestor, it returns ThemeData.menuBarTheme.
Typical usage is as follows:
Widget build(BuildContext context) {
return MenuTheme(
data: const MenuThemeData(
style: MenuStyle(
backgroundColor: MaterialStatePropertyAll<Color?>(Colors.red),
),
),
child: child,
);
}
Implementation
static MenuBarThemeData of(BuildContext context) {
final MenuBarTheme? menuBarTheme = context.dependOnInheritedWidgetOfExactType<MenuBarTheme>();
return menuBarTheme?.data ?? Theme.of(context).menuBarTheme;
}