Closed
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]
Metadata
Metadata
Assignees
Labels
It was better in the past than it is nowflutter/packages/flutter/material repository.Found to occur in 3.32Found to occur in 3.33flutter/packages/flutter repository. See also f: labels.The issue has been confirmed reproducible and is ready to work onIssue is closed as already fixed in a newer versionOwned by Design Languages team
Type
Projects
Status
Done (PR merged)