of<T extends CustomThemeData> static method

T? of<T extends CustomThemeData>(
  1. BuildContext context, {
  2. T? mainDefault,
  3. T? darkDefault,
})

Obtains the theme data of given type from the nearest storage.

If CustomThemes storage is not found and dafault data is not provided than returns null.

Implementation

static T? of<T extends CustomThemeData>(BuildContext context,
    {T? mainDefault, T? darkDefault}) {
  final isDark = Theme.of(context).brightness == Brightness.dark;
  return _of(context)?.get<T>(isDark ? _getDarkFunc<T>() : null) ??
      (isDark && darkDefault != null ? darkDefault : mainDefault);
}