of static method

Returns the nearest DraftModeUIThemeData above context.

Checks the DraftModeUITheme InheritedWidget first, then falls back to Theme.of(context).extension<DraftModeUIThemeData>(). Asserts in debug mode when neither path provides data.

Implementation

static DraftModeUIThemeData of(BuildContext context) {
  final widget =
      context.dependOnInheritedWidgetOfExactType<DraftModeUITheme>();
  if (widget != null) return widget.data;
  final ext = Theme.of(context).extension<DraftModeUIThemeData>();
  assert(
    ext != null,
    'No DraftModeUITheme or ThemeExtension<DraftModeUIThemeData> found',
  );
  return ext!;
}