of<T extends BreakpointSpec> static method

T of<T extends BreakpointSpec>(
  1. BuildContext context
)

Static helper to get the resolved breakpoint of type T from the current BuildContext.

Will throw an assert error if ResponsiveBreakpointTheme<T> is not found in the ThemeData.extensions.

Implementation

static T of<T extends BreakpointSpec>(BuildContext context) {
  final theme = Theme.of(context).extension<ResponsiveBreakpointTheme<T>>();
  assert(
    theme != null,
    'ResponsiveBreakpointTheme<$T> is not added to ThemeData.extensions',
  );
  return theme!.resolveBreakpoint(context);
}