From 0592905ad4b980fac0d2b3a6c1794f7899483601 Mon Sep 17 00:00:00 2001 From: fufesou Date: Sun, 1 Feb 2026 10:15:39 +0800 Subject: [PATCH] fix: dialog text color in dark theme Signed-off-by: fufesou --- flutter/lib/common.dart | 69 ++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart index 48f813f6d..b941632dd 100644 --- a/flutter/lib/common.dart +++ b/flutter/lib/common.dart @@ -1126,52 +1126,43 @@ Widget createDialogContent(String text) { final RegExp linkRegExp = RegExp(r'(https?://[^\s]+)'); bool hasLink = linkRegExp.hasMatch(text); + // Early return: no link, use default theme color if (!hasLink) { return SelectableText(text, style: const TextStyle(fontSize: 15)); } - return Builder( - builder: (context) { - final List spans = []; - int start = 0; - - // Get theme-aware color for non-link text - final textColor = Theme.of(context).textTheme.bodyMedium?.color; + final List spans = []; + int start = 0; - linkRegExp.allMatches(text).forEach((match) { - if (match.start > start) { - spans.add(TextSpan(text: text.substring(start, match.start))); - } - spans.add(TextSpan( - text: match.group(0) ?? '', - style: TextStyle( - color: Colors.blue, - decoration: TextDecoration.underline, - ), - recognizer: TapGestureRecognizer() - ..onTap = () { - String linkText = match.group(0) ?? ''; - linkText = linkText.replaceAll(RegExp(r'[.,;!?]+$'), ''); - launchUrl(Uri.parse(linkText)); - }, - )); - start = match.end; - }); + linkRegExp.allMatches(text).forEach((match) { + if (match.start > start) { + spans.add(TextSpan(text: text.substring(start, match.start))); + } + spans.add(TextSpan( + text: match.group(0) ?? '', + style: const TextStyle( + color: Colors.blue, + decoration: TextDecoration.underline, + ), + recognizer: TapGestureRecognizer() + ..onTap = () { + String linkText = match.group(0) ?? ''; + linkText = linkText.replaceAll(RegExp(r'[.,;!?]+$'), ''); + launchUrl(Uri.parse(linkText)); + }, + )); + start = match.end; + }); - if (start < text.length) { - spans.add(TextSpan(text: text.substring(start))); - } + if (start < text.length) { + spans.add(TextSpan(text: text.substring(start))); + } - return SelectableText.rich( - TextSpan( - style: TextStyle( - color: textColor, - fontSize: 15, - ), - children: spans, - ), - ); - }, + return SelectableText.rich( + TextSpan( + style: const TextStyle(fontSize: 15), + children: spans, + ), ); }