diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index 155103776..6a9009026 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -1003,14 +1003,15 @@ class FfiModel with ChangeNotifier { // Notify to switch display msgBox(sessionId, 'custom-nook-nocancel-hasclose-info', 'Prompt', 'display_is_plugged_out_msg', '', parent.target!.dialogManager); - final newDisplay = pi.primaryDisplay == kInvalidDisplayIndex - ? 0 - : pi.primaryDisplay; - final displays = newDisplay; + final isPeerPrimaryDisplayValid = + pi.primaryDisplay == kInvalidDisplayIndex || + pi.primaryDisplay >= pi.displays.length; + final newDisplay = + isPeerPrimaryDisplayValid ? 0 : pi.primaryDisplay; bind.sessionSwitchDisplay( isDesktop: isDesktop, sessionId: sessionId, - value: Int32List.fromList([displays]), + value: Int32List.fromList([newDisplay]), ); if (_pi.isSupportMultiUiSession) {