of method Null safety

MaterialBannerThemeData of(
  1. BuildContext context

The closest instance of this class's data value that encloses the given context.

If there is no ancestor, it returns ThemeData.bannerTheme. Applications can assume that the returned value will not be null.

Typical usage is as follows:

MaterialBannerThemeData theme = MaterialBannerTheme.of(context);


static MaterialBannerThemeData of(BuildContext context) {
  final MaterialBannerTheme? bannerTheme = context.dependOnInheritedWidgetOfExactType<MaterialBannerTheme>();
  return bannerTheme?.data ?? Theme.of(context).bannerTheme;