maybeOf static method

SegmentedButtonThemeData? maybeOf(
  1. BuildContext context
)

The data from the closest instance of this class that encloses the given context, if any.

Use this function if you want to allow situations where no SegmentedButtonTheme is in scope. Prefer using SegmentedButtonTheme.of in situations where a SegmentedButtonThemeData is expected to be non-null.

If there is no SegmentedButtonTheme in scope, then this function will return null.

Typical usage is as follows:

SegmentedButtonThemeData? theme = SegmentedButtonTheme.maybeOf(context);
if (theme == null) {
  // Do something else instead.
}

See also:

Implementation

static SegmentedButtonThemeData? maybeOf(BuildContext context) {
  return context.dependOnInheritedWidgetOfExactType<SegmentedButtonTheme>()?.data;
}