Repository navigation
[Flutter 3.32.0] Active NavigationBar item not selected when switching items programmatically #169249
Copy link
Copy link
Closed
Labels
c: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 3.32Found to occur in 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33Found to occur in 3.33frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages team
Description
Steps to reproduce
Press the Back-Key, trigger switching to first nav programmatically
Expected results
first nav will be selected
Actual results
selected nav is not changed
Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int index = 0;
@override
Widget build(BuildContext context) {
return PopScope(
canPop: false,
onPopInvokedWithResult: (didPop, result) {
if (index != 0) {
setState(() {
index = 0;
});
} else {
SystemNavigator.pop();
}
},
child: Scaffold(
appBar: AppBar(
title: const Text('Flutter Demo'),
),
body: Center(
child: Text(
index.toString(),
style: const TextStyle(fontSize: 25),
),
),
bottomNavigationBar: NavigationBar(
onDestinationSelected: (value) {
setState(() {
index = value;
});
},
selectedIndex: index,
destinations: const [
NavigationDestination(
icon: Icon(Icons.home),
label: 'Home',
),
NavigationDestination(
icon: Icon(Icons.settings),
label: 'Settings',
),
],
),
),
);
}
}Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
[Paste your output here]Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
c: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 3.32Found to occur in 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33Found to occur in 3.33frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages team
Type
Projects
- StatusShow more project fieldsDone (PR merged)
Activity
danagbemava-nc commentedon May 22, 2025
Reproducible using the code sample provided above.
cc @bleroux in case you might be interested
Screen.Recording.2025-05-22.at.9.02.18.AM.mov
Screen.Recording.2025-05-22.at.9.10.29.AM.mov
flutter doctor -v
[-]Flutter 3.32.0 NavigationBar not updating when switching programmatically[/-][+][Flutter 3.32.0] Active NavigationBar item not selected when switching items programmatically[/+]Revert "Fix NavigationBar indicator overlay color (#164484)" (#169497)
Revert "Fix NavigationBar indicator overlay color (flutter#164484)" (f…
[CP-stable]Revert "Fix NavigationBar indicator overlay color (#164484)…
github-actions commentedon Jun 26, 2025
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.