Skip to content

[Flutter 3.32.0] Active NavigationBar item not selected when switching items programmatically #169249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bggRGjQaUbCoE opened this issue May 22, 2025 · 1 comment
Labels
c: regression It was better in the past than it is now f: material design flutter/packages/flutter/material repository. found in release: 3.32 Found to occur in 3.32 found in release: 3.33 Found to occur in 3.33 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on team-design Owned by Design Languages team

Comments

@bggRGjQaUbCoE
Copy link

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]
@danagbemava-nc danagbemava-nc added the in triage Presently being triaged by the triage team label May 22, 2025
@danagbemava-nc
Copy link
Member

Reproducible using the code sample provided above.

cc @bleroux in case you might be interested

stable 3.32.0+ stable 3.29.3
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 (Channel stable, 3.32.0, on macOS 15.4 24E248 darwin-arm64, locale en-US) [1,073ms]
    • Flutter version 3.32.0 on channel stable at /Users/deanli/dev/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision be698c48a6 (3 days ago), 2025-05-19 12:59:14 -0700
    • Engine revision 1881800949
    • Dart version 3.8.0
    • DevTools version 2.45.1

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [3.5s]
    • Android SDK at /Users/deanli/Library/Android/sdk
    • Platform android-36, build-tools 36.0.0
    • Java binary at: /Users/deanli/Applications/Android Studio Meerkat Feature Drop 2024.3.2 RC 4.app/Contents/jbr/Contents/Home/bin/java
      This JDK is specified in your Flutter configuration.
      To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.4) [1,619ms]
    • Xcode at /Applications/Xcode-16.4.0-Beta.app/Contents/Developer
    • Build 16F1t
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [10ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [9ms]
    • Android Studio at /Users/deanli/Applications/Android Studio Meerkat Feature Drop 2024.3.2 RC 4.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /Users/deanli/Applications/Android Studio Meerkat Feature Drop 2024.3.2 RC 4.app
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)

[✓] Android Studio (version 2024.2) [8ms]
    • Android Studio at /Users/deanli/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)

[✓] VS Code (version 1.100.0) [8ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.110.0

[✓] Connected device (7 available) [7.1s]
    • sdk gphone64 arm64 (mobile)           • emulator-5554                        • android-arm64  • Android 16 (API 36) (emulator)
    • Dean’s iPad (wireless) (mobile)       • 00008103-000825C811E3401E            • ios            • iOS 18.5 22F75
    • iPhone 16 Pro Max (wireless) (mobile) • 00008140-00194CC23A68801C            • ios            • iOS 18.5 22F76
    • Nexus (wireless) (mobile)             • 00008020-001875E83A38002E            • ios            • iOS 18.4.1 22E252
    • iPhone 16 Pro (mobile)                • 63C28242-27C4-477D-A63A-BC88BADB1BCA • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-5 (simulator)
    • macOS (desktop)                       • macos                                • darwin-arm64   • macOS 15.4 24E248 darwin-arm64
    • Chrome (web)                          • chrome                               • web-javascript • Google Chrome 136.0.7103.114
    ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources [1,358ms]
    • All expected network resources are available.

• No issues found!
[!] Flutter (Channel master, 3.33.0-1.0.pre.162, on macOS 15.4 24E248 darwin-arm64, locale en-US) [3.2s]
    • Flutter version 3.33.0-1.0.pre.162 on channel master at /Users/deanli/dev/master
    ! Warning: `flutter` on your path resolves to /Users/deanli/dev/stable/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/deanli/dev/master. Consider adding /Users/deanli/dev/master/bin to the front of your path.
    ! Warning: `dart` on your path resolves to /Users/deanli/dev/stable/bin/dart, which is not inside your current Flutter SDK checkout at /Users/deanli/dev/master. Consider adding /Users/deanli/dev/master/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 88d184dada (6 hours ago), 2025-05-22 03:32:21 +0000
    • Engine revision 88d184dada
    • Dart version 3.9.0 (build 3.9.0-155.0.dev)
    • DevTools version 2.46.0
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [1,701ms]
    • Android SDK at /Users/deanli/Library/Android/sdk
    • Emulator version 35.5.9.0 (build_id 13248646) (CL:N/A)
    • Platform android-36, build-tools 36.0.0
    • Java binary at: /Users/deanli/Applications/Android Studio Meerkat Feature Drop 2024.3.2 RC 4.app/Contents/jbr/Contents/Home/bin/java
      This JDK is specified in your Flutter configuration.
      To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.4) [1,253ms]
    • Xcode at /Applications/Xcode-16.4.0-Beta.app/Contents/Developer
    • Build 16F1t
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [9ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [9ms]
    • Android Studio at /Users/deanli/Applications/Android Studio Meerkat Feature Drop 2024.3.2 RC 4.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /Users/deanli/Applications/Android Studio Meerkat Feature Drop 2024.3.2 RC 4.app
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)

[✓] Android Studio (version 2024.2) [8ms]
    • Android Studio at /Users/deanli/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)

[✓] VS Code (version 1.100.0) [8ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.110.0

[✓] Connected device (7 available) [6.7s]
    • sdk gphone64 arm64 (mobile)           • emulator-5554                        • android-arm64  • Android 16 (API 36) (emulator)
    • Dean’s iPad (wireless) (mobile)       • 00008103-000825C811E3401E            • ios            • iOS 18.5 22F75
    • iPhone 16 Pro Max (wireless) (mobile) • 00008140-00194CC23A68801C            • ios            • iOS 18.5 22F76
    • Nexus (wireless) (mobile)             • 00008020-001875E83A38002E            • ios            • iOS 18.4.1 22E252
    • iPhone 16 Pro (mobile)                • 63C28242-27C4-477D-A63A-BC88BADB1BCA • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-5 (simulator)
    • macOS (desktop)                       • macos                                • darwin-arm64   • macOS 15.4 24E248 darwin-arm64
    • Chrome (web)                          • chrome                               • web-javascript • Google Chrome 136.0.7103.114
    ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources [679ms]
    • All expected network resources are available.

! Doctor found issues in 1 category.

@danagbemava-nc danagbemava-nc added c: regression It was better in the past than it is now framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. has reproducible steps The issue has been confirmed reproducible and is ready to work on team-design Owned by Design Languages team found in release: 3.32 Found to occur in 3.32 found in release: 3.33 Found to occur in 3.33 and removed in triage Presently being triaged by the triage team labels May 22, 2025
@danagbemava-nc danagbemava-nc changed the title Flutter 3.32.0 NavigationBar not updating when switching programmatically [Flutter 3.32.0] Active NavigationBar item not selected when switching items programmatically May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: regression It was better in the past than it is now f: material design flutter/packages/flutter/material repository. found in release: 3.32 Found to occur in 3.32 found in release: 3.33 Found to occur in 3.33 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on team-design Owned by Design Languages team
Projects
None yet
Development

No branches or pull requests

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy