修正切换和国旗问题

(cherry picked from commit bec2464da85e981636077276de36b2ea5f6c40f4)
This commit is contained in:
2025-10-31 08:10:44 -07:00
committed by speakeloudest
parent 7083369cd4
commit 138209929b
5 changed files with 166 additions and 10 deletions
+28 -2
View File
@@ -37,12 +37,38 @@ class KRCountryFlag extends StatelessWidget {
@override
Widget build(BuildContext context) {
// 🔍 调试日志
print('🏳️ KRCountryFlag.build 被调用');
print(' - 原始 countryCode: "$countryCode"');
print(' - countryCode.isEmpty: ${countryCode.isEmpty}');
print(' - countryCode.length: ${countryCode.length}');
final processedCode = _getCountryCode(countryCode);
print(' - 处理后 code: "$processedCode"');
// 如果国家代码为空,显示占位符
if (countryCode.isEmpty) {
print(' ❌ 国家代码为空,显示占位符');
return Container(
width: width ?? 50.w,
height: height ?? 50.w,
decoration: BoxDecoration(
color: Colors.grey[300],
shape: isCircle ? BoxShape.circle : BoxShape.rectangle,
borderRadius: !isCircle ? BorderRadius.circular(8.w) : null,
),
child: Icon(Icons.flag, color: Colors.grey[600], size: 24.w),
);
}
// 计算实际尺寸
final double actualWidth = width ?? 50.w;
final double actualHeight = maintainSize ? actualWidth : (height ?? 50.w);
print(' ✅ 尝试加载国旗: $processedCode');
Widget flagWidget = CountryFlag.fromCountryCode(
_getCountryCode(countryCode),
processedCode,
width: actualWidth,
height: actualHeight,
);