of static method

Retrieves the ElevatedButtonThemeData from the closest ancestor ElevatedButtonTheme.

If there is no enclosing ElevatedButtonTheme widget, then ThemeData.elevatedButtonTheme is used.

The returned ElevatedButtonThemeData.variant is the value specified by that theme, which can be null even when an ancestor specifies a variant. Use variantOf to get the variant that applies at the given context.

Typical usage is as follows:

ElevatedButtonThemeData theme = ElevatedButtonTheme.of(context);

Implementation

static ElevatedButtonThemeData of(BuildContext context) {
  final ElevatedButtonTheme? buttonTheme = context
      .dependOnInheritedWidgetOfExactType<ElevatedButtonTheme>();
  return buttonTheme?.data ?? Theme.of(context).elevatedButtonTheme;
}