feat(client): context.tokens 取色扩展

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-24 21:44:03 +08:00
parent b69b3acaaf
commit ab34394109
2 changed files with 21 additions and 0 deletions
@@ -0,0 +1,6 @@
import 'package:flutter/material.dart';
import 'app_tokens.dart';
extension TokensX on BuildContext {
AppTokens get tokens => Theme.of(this).extension<AppTokens>()!;
}
@@ -0,0 +1,15 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:jiu_client/core/theme/context_tokens.dart';
import 'package:jiu_client/core/theme/themes.dart';
void main() {
testWidgets('context.tokens 取到当前主题色', (tester) async {
late Color seen;
await tester.pumpWidget(MaterialApp(
theme: buildTheme('a'),
home: Builder(builder: (ctx) { seen = ctx.tokens.primary; return const SizedBox(); }),
));
expect(seen, const Color(0xFF2563AC));
});
}