84a638a41f
Three classes:
1. album_cover_cache.dart docstring used <applicationCacheDirectory>
and <albumId> which the analyzer reads as unintended HTML. Wrapped
the path in backticks and used {} placeholders.
2. settings AppearanceSection used RadioListTile.groupValue + onChanged,
deprecated in Flutter 3.32+. Wrapped the radios in a RadioGroup
ancestor (the new API) so individual tiles only declare value +
activeColor. Test updated to read groupValue off the RadioGroup
ancestor.
3. theme_extension.dart factories built FabledSwordTheme(...) without
const, even though all args are static const tokens. Added const to
the outer constructor calls in both .dark() and .light() — this
propagates const to the inner TextStyle(...) calls automatically.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
94 lines
3.4 KiB
Dart
94 lines
3.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'tokens.dart';
|
|
|
|
class FabledSwordTheme extends ThemeExtension<FabledSwordTheme> {
|
|
const FabledSwordTheme({
|
|
required this.accent,
|
|
required this.obsidian,
|
|
required this.iron,
|
|
required this.slate,
|
|
required this.pewter,
|
|
required this.parchment,
|
|
required this.vellum,
|
|
required this.ash,
|
|
required this.moss,
|
|
required this.bronze,
|
|
required this.oxblood,
|
|
required this.warning,
|
|
required this.error,
|
|
required this.info,
|
|
required this.display,
|
|
required this.body,
|
|
required this.mono,
|
|
});
|
|
|
|
final Color accent;
|
|
final Color obsidian, iron, slate, pewter;
|
|
final Color parchment, vellum, ash;
|
|
final Color moss, bronze, oxblood;
|
|
final Color warning, error, info;
|
|
final TextStyle display, body, mono;
|
|
|
|
factory FabledSwordTheme.dark() => const FabledSwordTheme(
|
|
accent: FabledSwordFlatTokens.accent,
|
|
obsidian: FabledSwordDarkTokens.obsidian,
|
|
iron: FabledSwordDarkTokens.iron,
|
|
slate: FabledSwordDarkTokens.slate,
|
|
pewter: FabledSwordDarkTokens.pewter,
|
|
parchment: FabledSwordDarkTokens.parchment,
|
|
vellum: FabledSwordDarkTokens.vellum,
|
|
ash: FabledSwordDarkTokens.ash,
|
|
moss: FabledSwordFlatTokens.moss,
|
|
bronze: FabledSwordFlatTokens.bronze,
|
|
oxblood: FabledSwordFlatTokens.oxblood,
|
|
warning: FabledSwordFlatTokens.warning,
|
|
error: FabledSwordFlatTokens.error,
|
|
info: FabledSwordFlatTokens.info,
|
|
display: TextStyle(fontFamily: FabledSwordFlatTokens.fontDisplay),
|
|
body: TextStyle(fontFamily: FabledSwordFlatTokens.fontBody),
|
|
mono: TextStyle(fontFamily: FabledSwordFlatTokens.fontMono),
|
|
);
|
|
|
|
factory FabledSwordTheme.light() => const FabledSwordTheme(
|
|
accent: FabledSwordFlatTokens.accent,
|
|
obsidian: FabledSwordLightTokens.obsidian,
|
|
iron: FabledSwordLightTokens.iron,
|
|
slate: FabledSwordLightTokens.slate,
|
|
pewter: FabledSwordLightTokens.pewter,
|
|
parchment: FabledSwordLightTokens.parchment,
|
|
vellum: FabledSwordLightTokens.vellum,
|
|
ash: FabledSwordLightTokens.ash,
|
|
moss: FabledSwordFlatTokens.moss,
|
|
bronze: FabledSwordFlatTokens.bronze,
|
|
oxblood: FabledSwordFlatTokens.oxblood,
|
|
warning: FabledSwordFlatTokens.warning,
|
|
error: FabledSwordFlatTokens.error,
|
|
info: FabledSwordFlatTokens.info,
|
|
display: TextStyle(fontFamily: FabledSwordFlatTokens.fontDisplay),
|
|
body: TextStyle(fontFamily: FabledSwordFlatTokens.fontBody),
|
|
mono: TextStyle(fontFamily: FabledSwordFlatTokens.fontMono),
|
|
);
|
|
|
|
/// Back-compat alias for the original API. Returns the dark theme.
|
|
/// Existing call sites can keep using fromTokens() until they're
|
|
/// migrated to .dark() / .light() explicitly.
|
|
static FabledSwordTheme fromTokens() => FabledSwordTheme.dark();
|
|
|
|
@override
|
|
FabledSwordTheme copyWith({
|
|
Color? accent,
|
|
}) =>
|
|
FabledSwordTheme(
|
|
accent: accent ?? this.accent,
|
|
obsidian: obsidian, iron: iron, slate: slate, pewter: pewter,
|
|
parchment: parchment, vellum: vellum, ash: ash,
|
|
moss: moss, bronze: bronze, oxblood: oxblood,
|
|
warning: warning, error: error, info: info,
|
|
display: display, body: body, mono: mono,
|
|
);
|
|
|
|
@override
|
|
FabledSwordTheme lerp(ThemeExtension<FabledSwordTheme>? other, double t) => this;
|
|
}
|