ofType<T extends FirebaseUIStyle> static method

T ofType<T extends FirebaseUIStyle>(
  1. BuildContext context,
  2. T defaultValue
)

Resolves the style object via BuildContext and provides a defaultValue if none was found.

Implementation

static T ofType<T extends FirebaseUIStyle>(
  BuildContext context,
  T defaultValue,
) {
  final el =
      context.getElementForInheritedWidgetOfExactType<FirebaseUITheme>();
  if (el == null) return defaultValue;

  context.dependOnInheritedElement(el, aspect: T);
  final style = (el as FirebaseUIThemeElement).styles[T];

  if (style == null) return defaultValue;
  return style as T;
}