1671edd913
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
25 lines
679 B
Dart
25 lines
679 B
Dart
import 'package:flutter/material.dart';
|
|
import 'app_tokens.g.dart';
|
|
|
|
ThemeData buildTheme(String key) {
|
|
final t = appTokensOf(key);
|
|
final brightness = t.isDark ? Brightness.dark : Brightness.light;
|
|
final scheme = ColorScheme.fromSeed(
|
|
seedColor: t.primary,
|
|
brightness: brightness,
|
|
).copyWith(
|
|
primary: t.primary,
|
|
onPrimary: t.onPrimary,
|
|
surface: t.surface,
|
|
error: t.danger,
|
|
);
|
|
return ThemeData(
|
|
useMaterial3: true,
|
|
brightness: brightness,
|
|
colorScheme: scheme,
|
|
scaffoldBackgroundColor: t.bg,
|
|
fontFamily: null, // 系统中文字体;字号梯度后续在组件层接入
|
|
extensions: <ThemeExtension<dynamic>>[t],
|
|
);
|
|
}
|