themeData method

MaterialTheme themeData(
  1. DartValue? v, {
  2. required MaterialTheme current,
})

Evaluates a ThemeData expression. current is the ambient theme, used for Theme.of(context) and as the fallback.

Implementation

MaterialTheme themeData(DartValue? v, {required MaterialTheme current}) {
  final d = eval.deref(v);
  switch (d) {
    case ObjectValue(type: 'ThemeData', :final constructor):
      return switch (constructor) {
        null || 'from' => _build(d.named, d),
        'light' ||
        'fallback' => MaterialTheme.baseline(ThemeBrightness.light),
        'dark' => MaterialTheme.baseline(ThemeBrightness.dark),
        _ => _unresolved(d, current),
      };
    case CallValue(target: final target?, method: 'copyWith'):
      return _copyWith(themeData(target, current: current), d.named, d);
    case CallValue(target: RefValue(last: 'Theme'), method: 'of'):
      return current;
    default:
      return _unresolved(d, current);
  }
}