diff --git a/frontend/genex-mobile/lib/core/updater/channels/self_hosted_updater.dart b/frontend/genex-mobile/lib/core/updater/channels/self_hosted_updater.dart index fb27e1e..baad9ab 100644 --- a/frontend/genex-mobile/lib/core/updater/channels/self_hosted_updater.dart +++ b/frontend/genex-mobile/lib/core/updater/channels/self_hosted_updater.dart @@ -246,19 +246,26 @@ class _DownloadProgressDialogState extends State<_DownloadProgressDialog> { bool _hasError = false; bool _downloadCompleted = false; File? _downloadedApkFile; + // 防止 didChangeDependencies 多次触发时重复启动下载 + bool _downloadStarted = false; @override void initState() { super.initState(); - _startDownload(); + // 不在 initState 里调用 context.t(),需要等 inherited widget 挂载完成 } @override void didChangeDependencies() { super.didChangeDependencies(); + // didChangeDependencies 是首次可安全使用 context.t() 的时机 if (_statusText.isEmpty) { _statusText = context.t('update.preparing'); } + if (!_downloadStarted) { + _downloadStarted = true; + _startDownload(); + } } Future _startDownload() async {