Fix update dialog: show errors, handle OpenFile result correctly
- Check OpenResult.type before resetting state — previously a failed open_file call (e.g. installer blocked on emulator) silently called state = const UpdateState(), nulling latestVersion and downloadUrl, causing "Version null" and a non-functional Download button - Show errorMessage in dialog with error colour so failures are visible - Guard Download button on downloadUrl != null (no button if URL lost) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -119,14 +119,20 @@ class UpdateNotifier extends Notifier<UpdateState> {
|
||||
},
|
||||
);
|
||||
|
||||
await OpenFile.open(
|
||||
final result = await OpenFile.open(
|
||||
path,
|
||||
type: 'application/vnd.android.package-archive',
|
||||
);
|
||||
|
||||
// Transition to idle — the system installer is now open.
|
||||
// Going back to `available` would re-trigger the update dialog loop.
|
||||
state = const UpdateState();
|
||||
if (result.type == ResultType.done) {
|
||||
// Installer launched — reset to idle so the dialog closes naturally.
|
||||
state = const UpdateState();
|
||||
} else {
|
||||
state = state.copyWith(
|
||||
status: UpdateStatus.error,
|
||||
errorMessage: 'Could not open installer: ${result.message}',
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
state = state.copyWith(
|
||||
status: UpdateStatus.error,
|
||||
|
||||
Reference in New Issue
Block a user