Skip to content

Commit

Permalink
Fix index out of range error when animating to a tab (#6455)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenzieschmoll authored Sep 23, 2023
1 parent 80f8fb7 commit 0340fc0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/devtools_app/lib/src/framework/scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,13 @@ class DevToolsScaffoldState extends State<DevToolsScaffold>
} else if (widget.screens[_tabController!.index].screenId != widget.page) {
// If the page changed (eg. the route was modified by pressing back in the
// browser), animate to the new one.
final newIndex = widget.page == null
var newIndex = widget.page == null
? 0 // When there's no supplied page, we show the first one.
: widget.screens.indexWhere((t) => t.screenId == widget.page);
// Ensure the returned index is in range, otherwise set to 0.
if (newIndex == -1) {
newIndex = 0;
}
_tabController!.animateTo(newIndex);
}
}
Expand Down

0 comments on commit 0340fc0

Please sign in to comment.