of static method

SnackBarThemeData 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.snackBarTheme. Applications can assume that the returned value will not be null.

Typical usage is as follows:

SnackBarThemeData theme = SnackBarTheme.of(context);

Implementation

static SnackBarThemeData of(BuildContext context) {
  final SnackBarTheme? snackBarTheme = context
      .dependOnInheritedWidgetOfExactType<SnackBarTheme>();
  return snackBarTheme?.data ?? Theme.of(context).snackBarTheme;
}