customDataOf<T> static method

T? customDataOf<T>(
  1. BuildContext context, [
  2. ThemeType type = ThemeType.custom
])

customData could be null. always check for null before using.

ThemeManager.customDataOf<ExampleClass>(context)?.example ?? null

to get data for current cupertino theme

ThemeManager.customDataOf<ExampleClass>(context, ThemeType.cupertino)?.example

Implementation

static T? customDataOf<T>(BuildContext context,
    [ThemeType type = ThemeType.custom]) {
  _ThemeManager? inherited =
      (context.dependOnInheritedWidgetOfExactType<_ThemeManager>());
  switch (type) {
    case ThemeType.material:
      return inherited!
          .data!.customDataMap[inherited.data!.currentThemeKey!]?.data as T?;
    case ThemeType.cupertino:
      return inherited!
          .data!
          .customDataMap[inherited.data!.currentCupertinoThemeKey!]
          ?.data as T?;
    case ThemeType.custom:
      return inherited!.data!
          .customDataMap[inherited.data!.currentCustomDataKey!]?.data as T?;
    default:
      return inherited!.data!
          .customDataMap[inherited.data!.currentCustomDataKey!]?.data as T?;
  }
}