import 'dart:convert'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; /// 应用「关于我们」等品牌信息,从配置文件 assets/config/app_info.json 读取, /// 不硬编码、不走环境变量。在 main() 启动时调用 [load] 加载一次。 class AppInfo { const AppInfo._(); static const _assetPath = 'assets/config/app_info.json'; static String provider = ''; static String website = ''; static String email = ''; static String phone = ''; static String wechat = ''; static String termsUrl = ''; static String privacyUrl = ''; static String docsUrl = ''; /// 加载配置文件。失败时保留为空(不影响应用启动)。 static Future load() async { try { final raw = await rootBundle.loadString(_assetPath); final map = jsonDecode(raw) as Map; provider = (map['provider'] as String?) ?? ''; website = (map['website'] as String?) ?? ''; email = (map['email'] as String?) ?? ''; phone = (map['phone'] as String?) ?? ''; wechat = (map['wechat'] as String?) ?? ''; termsUrl = (map['terms_url'] as String?) ?? ''; privacyUrl = (map['privacy_url'] as String?) ?? ''; docsUrl = (map['docs_url'] as String?) ?? ''; } catch (e) { debugPrint('AppInfo.load failed: $e'); } } }