maybeOf<T> static method

FlutterFolderViewTheme<T> maybeOf<T>(
  1. BuildContext context
)

Retrieves the FlutterFolderViewTheme from the closest FolderViewTheme ancestor without registering a dependency

This is useful when you just need to read the theme once without needing to rebuild when the theme changes.

If there is no FolderViewTheme<T> ancestor, returns a default light theme, and reports a mismatched type in debug as of does.

Implementation

static FlutterFolderViewTheme<T> maybeOf<T>(BuildContext context) {
  final FolderViewTheme<T>? theme = context
      .getInheritedWidgetOfExactType<FolderViewTheme<T>>();
  if (theme == null) _debugReportTypeMismatch<T>(context);
  return theme?.data ?? FlutterFolderViewTheme<T>.light();
}