maybeOf<S extends Spec<S>> static method

Style<S>? maybeOf<S extends Spec<S>>(
  1. BuildContext context
)

Gets the closest Style from the widget tree, or null if not found.

Implementation

static Style<S>? maybeOf<S extends Spec<S>>(BuildContext context) {
  final provider = context.getInheritedWidgetOfExactType<StyleProvider<S>>();

  return provider?.style;
}