fix: Web 平台 Platform.operatingSystemVersion 不支持降级处理
CI / flutter-gates (push) Successful in 1m5s

AnalyticsService._defaultOsVersion() 在 Web 平台调用 Platform.operatingSystemVersion
会抛 UnsupportedError,导致 flutter run -d chrome 启动崩溃。加 kIsWeb 判断,
Web 平台降级为 'web-unknown',Android/iOS 保持动态读取不变。

复现:flutter run -d chrome → 报错 analytics_service.dart:53
修复后:Web 平台正常启动;51 测试全绿、flutter analyze 0 问题。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-07 15:44:17 +08:00
parent 6fef0db009
commit 8ea6265046
+4
View File
@@ -47,7 +47,11 @@ class AnalyticsService {
List.unmodifiable(_pendingEvents);
/// 粗粒度 osVersion13 号规范 §4.0:主版本级,如 android-14)。
/// Web 平台不支持 Platform.operatingSystemVersion,降级为 'web-unknown'。
static String _defaultOsVersion() {
if (kIsWeb) {
return 'web-unknown';
}
final major = RegExp(
r'\d+',
).firstMatch(Platform.operatingSystemVersion)?.group(0);