Skip to content

CupertinoNavigationBarBackButton crashes #89888

Closed
flutter/packages
#13397

Description

@fatadel

Steps to Reproduce

  1. Run flutter create bug.
  2. Replace contents of main.dart file with the following:
import 'package:flutter/cupertino.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return CupertinoApp(
      title: 'Flutter Demo',
      home: MyHomePage(),
      routes: {
        '/another-page': (context) => AnotherPage(),
      },
    );
  }
}

class MyHomePage extends StatelessWidget {
  MyHomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return CupertinoTabScaffold(
      tabBar: CupertinoTabBar(
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: const Icon(CupertinoIcons.map),
            label: 'Page 1',
          ),
          BottomNavigationBarItem(
            icon: const Icon(CupertinoIcons.map),
            label: 'Page 2',
          ),
          BottomNavigationBarItem(
            icon: const Icon(CupertinoIcons.map),
            label: 'Page 3',
          ),
        ],
      ),
      tabBuilder: (context, i) {
        return CupertinoPageScaffold(
          navigationBar: CupertinoNavigationBar(
            middle: Text('Page $i'),
          ),
          child: SafeArea(
            child: Center(
              child: Container(
                width: double.infinity,
                height: 200,
                child: Column(
                  children: [
                    Text('Hello from Page $i!'),
                    CupertinoButton(
                      child: Text('Go to another page'),
                      onPressed: () =>
                          Navigator.of(context).pushNamed('/another-page'),
                    ),
                  ],
                ),
              ),
            ),
          ),
        );
      },
    );
  }
}

class AnotherPage extends StatelessWidget {
  const AnotherPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    print(ModalRoute.of(context)!.canPop);

    return CupertinoPageScaffold(
      navigationBar: CupertinoNavigationBar(
        leading: CupertinoNavigationBarBackButton(
          color: CupertinoColors.black,
        ),
        middle: Text('Another Page'),
      ),
      child: Center(
        child: Text('Hello from Another Page!'),
      ),
    );
  }
}

Run on iOS and click the button to go to Another Page.

Expected results: CupertinoNavigationBarBackButton works normally because the page where it's used indeed can pop.

Actual results: You will see the red box error on page transitions (back and forward) and the following message in the logs:

flutter: true

======== Exception caught by widgets library =======================================================
The following assertion was thrown building CupertinoNavigationBarBackButton(dirty):
CupertinoNavigationBarBackButton should only be used in routes that can be popped
'package:flutter/src/cupertino/nav_bar.dart':
Failed assertion: line 1312 pos 9: 'currentRoute?.canPop == true'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

The relevant error-causing widget was: 
  CupertinoNavigationBarBackButton file:///%PATH_TO_PROJECT%/lib/main.dart:81:18
When the exception was thrown, this was the stack: 
#2      CupertinoNavigationBarBackButton.build (package:flutter/src/cupertino/nav_bar.dart:1312:9)
#3      StatelessElement.build (package:flutter/src/widgets/framework.dart:4648:28)
#4      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4574:15)
#5      Element.rebuild (package:flutter/src/widgets/framework.dart:4267:5)
#6      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4553:5)
...
====================================================================================================

  1. Output of flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.5.2 20G95 darwin-arm, locale ru-RU)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[!] Android Studio (version 2020.3)
    ✗ Unable to find bundled Java version.
[✓] VS Code (version 1.60.0)
[✓] Connected device (3 available)

! Doctor found issues in 1 category.

Activity

  1. added
    in triage
    on Sep 13, 2021
  2. danagbemava-nc commented on Sep 13, 2021

    @danagbemava-nc
    Member

    Issue is reproducible on latest stable and master.

    logs
    Launching lib/issue_89888.dart on iPhone 12 in debug mode...
    Xcode build done.                                           21.2s
    Connecting to VM Service at ws://127.0.0.1:59263/87ly7mZFhcU=/ws
    flutter: true
    
    ════════ Exception caught by widgets library ═══════════════════════════════════
    The following assertion was thrown building CupertinoNavigationBarBackButton(dirty):
    CupertinoNavigationBarBackButton should only be used in routes that can be popped
    'package:flutter/src/cupertino/nav_bar.dart':
    Failed assertion: line 1336 pos 9: 'currentRoute?.canPop == true'
    
    
    Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
    In either case, please report this assertion by filing a bug on GitHub:
      https://github.com/flutter/flutter/issues/new?template=2_bug.md
    
    The relevant error-causing widget was
    CupertinoNavigationBarBackButton CupertinoNavigationBarBackButton:file:///Users/nexus/projects/nevercode/w6/lib/issue_89888.dart:80:18
    When the exception was thrown, this was the stack
    #2      CupertinoNavigationBarBackButton.build
    #3      StatelessElement.build
    #4      ComponentElement.performRebuild
    #5      Element.rebuild
    #6      ComponentElement._firstBuild
    #7      ComponentElement.mount
    ...     Normal element mounting (25 frames)
    #32     Element.inflateWidget
    #33     MultiChildRenderObjectElement.inflateWidget
    #34     MultiChildRenderObjectElement.mount
    ...     Normal element mounting (53 frames)
    #87     Element.inflateWidget
    #88     MultiChildRenderObjectElement.inflateWidget
    #89     Element.updateChild
    #90     RenderObjectElement.updateChildren
    #91     MultiChildRenderObjectElement.update
    #92     Element.updateChild
    #93     ComponentElement.performRebuild
    #94     StatefulElement.performRebuild
    #95     Element.rebuild
    #96     BuildOwner.buildScope
    #97     WidgetsBinding.drawFrame
    #98     RendererBinding._handlePersistentFrameCallback
    #99     SchedulerBinding._invokeFrameCallback
    #100    SchedulerBinding.handleDrawFrame
    #101    SchedulerBinding._handleDrawFrame
    #105    _invoke (dart:ui/hooks.dart:166:10)
    #106    PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:270:5)
    #107    _drawFrame (dart:ui/hooks.dart:129:31)
    (elided 5 frames from class _AssertionError and dart:async)
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by widgets library ═══════════════════════════════════
    CupertinoNavigationBarBackButton should only be used in routes that can be popped
    'package:flutter/src/cupertino/nav_bar.dart':
    Failed assertion: line 1336 pos 9: 'currentRoute?.canPop == true'
    
    The relevant error-causing widget was
    CupertinoNavigationBarBackButton CupertinoNavigationBarBackButton:file:///Users/nexus/projects/nevercode/w6/lib/issue_89888.dart:80:18
    ════════════════════════════════════════════════════════════════════════════════
    Application finished.
    Exited (sigterm)
    
    flutter doctor -v
    [✓] Flutter (Channel master, 2.6.0-1.0.pre.256, on macOS 11.5.1 20G80 darwin-arm, locale en-GB)
        • Flutter version 2.6.0-1.0.pre.256 at /Users/nexus/dev/sdks/flutters
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 0d0f7a4fb0 (10 hours ago), 2021-09-12 21:17:23 -0700
        • Engine revision abb1980f65
        • Dart version 2.15.0 (build 2.15.0-96.0.dev)
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0
        • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 12.5.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • CocoaPods version 1.11.0
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2020.3)
        • Android Studio at /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 11.0.10+0-b96-7249189)
    
    [✓] VS Code (version 1.60.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.26.0
    
    [✓] Connected device (4 available)
        • Nexus’ IPhone (mobile) • 00008020-001875E83A38002E            • ios            • iOS 14.7.1 18G82
        • iPhone 12 (mobile)     • F2592D43-5FE3-46BB-8A2B-A38BA468DCE9 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
        • macOS (desktop)        • macos                                • darwin-arm64   • macOS 11.5.1 20G80 darwin-arm
        • Chrome (web)           • chrome                               • web-javascript • Google Chrome 93.0.4577.63
    
    • No issues found!
    [✓] Flutter (Channel stable, 2.5.0, on macOS 11.5.1 20G80 darwin-arm, locale en-GB)
        • Flutter version 2.5.0 at /Users/nexus/dev/sdks/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 4cc385b4b8 (5 days ago), 2021-09-07 23:01:49 -0700
        • Engine revision f0826da7ef
        • Dart version 2.14.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0
        • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.5.1, Build version 12E507
        • CocoaPods version 1.11.0
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2020.3)
        • Android Studio at /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 11.0.10+0-b96-7249189)
    
    [✓] VS Code (version 1.60.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.26.0
    
    [✓] Connected device (4 available)
        • Nexus’ IPhone (mobile) • 00008020-001875E83A38002E            • ios            • iOS 14.7.1 18G82
        • iPhone 12 (mobile)     • F2592D43-5FE3-46BB-8A2B-A38BA468DCE9 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
        • macOS (desktop)        • macos                                • darwin-arm64   • macOS 11.5.1 20G80 darwin-arm
        • Chrome (web)           • chrome                               • web-javascript • Google Chrome 93.0.4577.63
    
    • No issues found!
  3. added
    p: cupertino_ui
    found in release: 2.5
    found in release: 2.6
    framework
    has reproducible steps
    and removed
    in triage
    on Sep 13, 2021
  4. TahaTesser commented on Oct 4, 2021

    @TahaTesser
    Contributor

    Used the following minimal code sample

    complete minimal runnable code sample
    import 'package:flutter/cupertino.dart';
    
    void main() => runApp(MyApp());
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return CupertinoApp(
          title: 'Cupertino App',
          home: Home(),
        );
      }
    }
    
    class Home extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return CupertinoPageScaffold(
          navigationBar: CupertinoNavigationBar(
            middle: Text('Cupertino App Bar'),
          ),
          child: Center(
            child: CupertinoButton(
              child: Text('Go to second'),
              onPressed: () => Navigator.of(context).push(
                CupertinoPageRoute(
                  builder: (context) => AnotherPage(),
                ),
              ),
            ),
          ),
        );
      }
    }
    
    class AnotherPage extends StatelessWidget {
      const AnotherPage({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        // final ModalRoute<dynamic>? currentRoute = ModalRoute.of(context);
        // print('canPop? - ${currentRoute?.canPop}');
    
        return CupertinoPageScaffold(
          navigationBar: CupertinoNavigationBar(
            leading: CupertinoNavigationBarBackButton(
              color: CupertinoColors.black,
              onPressed: () {},
            ),
            middle: Text('Another Page'),
          ),
          child: Center(
            child: CupertinoButton(
              child: Text('Press me'),
              onPressed: () {
                print(ModalRoute.of(context)!.canPop);
              },
            ),
          ),
        );
      }
    }

    I just dug deeper into this, the main exception is thrown because when implementing CupertinoNavigationBarBackButton because currentRoute?.canPop is temporarily returned null during the transition with CupertinoNavigationBarBackButton

    main.dart

          navigationBar: CupertinoNavigationBar(
            leading: CupertinoNavigationBarBackButton(
              color: CupertinoColors.black,
              onPressed: () {},
            ),
            middle: Text('Another Page'),
          ),

    nav_bar.dart

      Widget build(BuildContext context) {
        final ModalRoute<dynamic>? currentRoute = ModalRoute.of(context);
        print(
            'CupertinoNavigationBarBackButton.build.canPop? - ${currentRoute?.canPop}');
        if (onPressed == null) {
          assert(
            currentRoute?.canPop == true,
            'CupertinoNavigationBarBackButton should only be used in routes that can be popped',
          );
        }

    Initially currentRoute?.canPop it returns true > null > true again

    Logs

    flutter: CupertinoNavigationBarBackButton.build.canPop? - true
    flutter: CupertinoNavigationBarBackButton.build.canPop? - null
    flutter: CupertinoNavigationBarBackButton.build.canPop? - true

    Now try commenting CupertinoNavigationBarBackButton, currentRoute?.canPopdoesn't go null anymore

    main.dart

            // leading: CupertinoNavigationBarBackButton(
            //   color: CupertinoColors.black,
            //   onPressed: () {},
            // ),

    Logs

    flutter: CupertinoNavigationBarBackButton.build.canPop? - true
    flutter: CupertinoNavigationBarBackButton.build.canPop? - true
    flutter: CupertinoNavigationBarBackButton.build.canPop? - true

    CC: @chunhtai
    I see that you've worked on improving canPop logic in this PR #73993 which also includes a test for CupertinoNavigationBarBackButton. Do you've any hints as to where we can fix this? I would love to help.

  5. ynnob commented on Jan 20, 2023

    @ynnob

    I think this is still not fixed.

    Breaks when we navigate from a CupertinoPageScaffold page to a second CupertinoPageScaffold that implements a CupertinoNavigationBarBackButton. If you remove the CupertinoNavigationBarBackButton or add a manual onPressed method that will pop the navigation stack it will work and no assertion error is thrown.

    Also if you navigate from a normal Scaffold to the CupertinoPageScaffold that implements CupertinoNavigationBarBackButton it will work. it only seems to break when the calling page is also a CupertinoPageScaffold.

    CupertinoPageScaffold(
                  navigationBar: CupertinoNavigationBar(
                    backgroundColor: CupertinoColors.activeGreen,
                    border: null,
                    padding: EdgeInsetsDirectional.all(0),
                    leading: CupertinoNavigationBarBackButton(
                      color: CupertinoColors.label,
                    ),
                  ),
                  child: Center(
                    child: Text('CupertinoNavigationBar'),
                  ),
                )
    

    Error:

    ════════ Exception caught by widgets library ═══════════════════════════════════
    The following assertion was thrown building CupertinoNavigationBarBackButton(dirty):
    CupertinoNavigationBarBackButton should only be used in routes that can be popped
    'package:flutter/src/cupertino/nav_bar.dart':
    package:flutter/…/cupertino/nav_bar.dart:1
    Failed assertion: line 1336 pos 9: 'currentRoute?.canPop ?? false'
    
    Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
    In either case, please report this assertion by filing a bug on GitHub:
      https://github.com/flutter/flutter/issues/new?template=2_bug.md
    
  6. added
    team-design
    triaged-design
    on Jul 8, 2023
  7. erkinovalim commented on May 4, 2025

    @erkinovalim

    Is there a solution for this yet??? I am also facing this problem

  8. 1 remaining item

  9. removed
    triaged-design
    on May 4, 2025
  10. flutter-triage-bot commented on May 4, 2025

    @flutter-triage-bot

    This issue is missing a priority label. Please set a priority label when adding the triaged-design label.

  11. added
    workaround available
    on May 7, 2025
  12. changed the title [-]CupertinoNavigationBarBackButton works incorrectly[/-] [+]CupertinoNavigationBarBackButton crashes[/+] on May 14, 2025
  13. added
    P2
    triaged-design
    on May 14, 2025
  14. tirth-patel-nc commented on May 15, 2025

    @tirth-patel-nc
    Member

    Triage Report

    I was able to reproduce the issue using the provided code sample on both the stable (3.29.3) and master (3.33.0-1.0.pre.83) channels.

    Android iOS
    Screen.Recording.2025-05-15.at.8.50.42.PM.mov
    Simulator.Screen.Recording.-.iPhone.16.Plus.-.2025-05-15.at.20.52.41.mp4
    Error Log
    Restarted application in 396ms.
    I/flutter (11880): true
    
    ════════ Exception caught by widgets library ═══════════════════════════════════
    The following assertion was thrown building CupertinoNavigationBarBackButton(dirty):
    CupertinoNavigationBarBackButton should only be used in routes that can be popped
    'package:flutter/src/cupertino/nav_bar.dart':
    Failed assertion: line 2281 pos 9: 'currentRoute?.canPop ?? false'
    
    Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
    In either case, please report this assertion by filing a bug on GitHub:
      https://github.com/flutter/flutter/issues/new?template=02_bug.yml
    
    The relevant error-causing widget was:
        CupertinoNavigationBarBackButton CupertinoNavigationBarBackButton:file:///Users/tirthpatel/StudioProjects/hello_world/lib/main.dart:81:18
    
    When the exception was thrown, this was the stack:
    #2      CupertinoNavigationBarBackButton.build (package:flutter/src/cupertino/nav_bar.dart:2281:9)
    #3      StatelessElement.build (package:flutter/src/widgets/framework.dart:5781:49)
    #4      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5715:15)
    #5      Element.rebuild (package:flutter/src/widgets/framework.dart:5427:7)
    #6      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:5697:5)
    #7      ComponentElement.mount (package:flutter/src/widgets/framework.dart:5691:5)
    ...     Normal element mounting (31 frames)
    #38     Element.inflateWidget (package:flutter/src/widgets/framework.dart:4539:16)
    #39     MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:7159:36)
    #40     MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:7175:32)
    ...     Normal element mounting (70 frames)
    #110    Element.inflateWidget (package:flutter/src/widgets/framework.dart:4539:16)
    #111    MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:7159:36)
    #112    Element.updateChild (package:flutter/src/widgets/framework.dart:4004:18)
    #113    Element.updateChildren (package:flutter/src/widgets/framework.dart:4201:11)
    #114    MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:7192:17)
    #115    Element.updateChild (package:flutter/src/widgets/framework.dart:3982:15)
    #116    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5738:16)
    #117    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5874:11)
    #118    Element.rebuild (package:flutter/src/widgets/framework.dart:5427:7)
    #119    BuildScope._tryRebuild (package:flutter/src/widgets/framework.dart:2694:15)
    #120    BuildScope._flushDirtyElements (package:flutter/src/widgets/framework.dart:2752:11)
    #121    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:3056:18)
    #122    WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:1259:21)
    #123    RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:495:5)
    #124    SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1438:15)
    #125    SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1351:9)
    #126    SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1204:5)
    #127    _invoke (dart:ui/hooks.dart:331:13)
    #128    PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:444:5)
    #129    _drawFrame (dart:ui/hooks.dart:303:31)
    (elided 2 frames from class _AssertionError)
    
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by widgets library ═══════════════════════════════════
    CupertinoNavigationBarBackButton should only be used in routes that can be popped
    'package:flutter/src/cupertino/nav_bar.dart':
    Failed assertion: line 2281 pos 9: 'currentRoute?.canPop ?? false'
    The relevant error-causing widget was:
        CupertinoNavigationBarBackButton CupertinoNavigationBarBackButton:file:///Users/tirthpatel/StudioProjects/hello_world/lib/main.dart:81:18
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by scheduler library ═════════════════════════════════
    'package:flutter/src/widgets/heroes.dart': Failed assertion: line 762 pos 14: 'manifest.fromHero != newManifest.fromHero': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    W/WindowOnBackDispatcher(11880): sendCancelIfRunning: isInProgress=false callback=io.flutter.embedding.android.FlutterActivity$1@e968353
    I/flutter (11880): true
    
    ════════ Exception caught by widgets library ═══════════════════════════════════
    CupertinoNavigationBarBackButton should only be used in routes that can be popped
    'package:flutter/src/cupertino/nav_bar.dart':
    Failed assertion: line 2281 pos 9: 'currentRoute?.canPop ?? false'
    The relevant error-causing widget was:
        CupertinoNavigationBarBackButton CupertinoNavigationBarBackButton:file:///Users/tirthpatel/StudioProjects/hello_world/lib/main.dart:81:18
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by widgets library ═══════════════════════════════════
    CupertinoNavigationBarBackButton should only be used in routes that can be popped
    'package:flutter/src/cupertino/nav_bar.dart':
    Failed assertion: line 2281 pos 9: 'currentRoute?.canPop ?? false'
    The relevant error-causing widget was:
        CupertinoNavigationBarBackButton CupertinoNavigationBarBackButton:file:///Users/tirthpatel/StudioProjects/hello_world/lib/main.dart:81:18
    ════════════════════════════════════════════════════════════════════════════════
    W/WindowOnBackDispatcher(11880): sendCancelIfRunning: isInProgress=false callback=io.flutter.embedding.android.FlutterActivity$1@e968353
    
    ════════ Exception caught by scheduler library ═════════════════════════════════
    'package:flutter/src/widgets/heroes.dart': Failed assertion: line 762 pos 14: 'manifest.fromHero != newManifest.fromHero': is not true.
    ════════════════════════════════════════════════════════════════════════════════
    
    Code Sample
    // ignore_for_file: avoid_print
    
    import 'package:flutter/cupertino.dart';
    
    void main() {
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return CupertinoApp(
          title: 'Flutter Demo',
          home: MyHomePage(),
          routes: {'/another-page': (context) => AnotherPage()},
        );
      }
    }
    
    class MyHomePage extends StatelessWidget {
      const MyHomePage({super.key});
    
      @override
      Widget build(BuildContext context) {
        return CupertinoTabScaffold(
          tabBar: CupertinoTabBar(
            items: const <BottomNavigationBarItem>[
              BottomNavigationBarItem(
                icon: Icon(CupertinoIcons.map),
                label: 'Page 1',
              ),
              BottomNavigationBarItem(
                icon: Icon(CupertinoIcons.map),
                label: 'Page 2',
              ),
              BottomNavigationBarItem(
                icon: Icon(CupertinoIcons.map),
                label: 'Page 3',
              ),
            ],
          ),
          tabBuilder: (context, i) {
            return CupertinoPageScaffold(
              navigationBar: CupertinoNavigationBar(middle: Text('Page $i')),
              child: SafeArea(
                child: Center(
                  child: SizedBox(
                    width: double.infinity,
                    height: 200,
                    child: Column(
                      children: [
                        Text('Hello from Page $i!'),
                        CupertinoButton(
                          child: Text('Go to another page'),
                          onPressed:
                              () =>
                                  Navigator.of(context).pushNamed('/another-page'),
                        ),
                      ],
                    ),
                  ),
                ),
              ),
            );
          },
        );
      }
    }
    
    class AnotherPage extends StatelessWidget {
      const AnotherPage({super.key});
    
      @override
      Widget build(BuildContext context) {
        print(ModalRoute.of(context)!.canPop);
    
        return CupertinoPageScaffold(
          navigationBar: CupertinoNavigationBar(
            leading: CupertinoNavigationBarBackButton(color: CupertinoColors.black),
            middle: Text('Another Page'),
          ),
          child: Center(child: Text('Hello from Another Page!')),
        );
      }
    }
    stable (3.29.3) - flutter doctor -v
    [✓] Flutter (Channel stable, 3.29.3, on macOS 15.4.1 24E263 darwin-arm64, locale
        en-IN) [970ms]
        • Flutter version 3.29.3 on channel stable at
          /Users/tirthpatel/Development/flutter_stable/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision ea121f8859 (4 weeks ago), 2025-04-11 19:10:07 +0000
        • Engine revision cf56914b32
        • Dart version 3.7.2
        • DevTools version 2.42.3
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
        [855ms]
        • Android SDK at /Users/tirthpatel/Library/Android/sdk
        • Platform android-36, build-tools 36.0.0
        • Java binary at: /Applications/Android
          Studio.app/Contents/jbr/Contents/Home/bin/java
          This is the JDK bundled with the latest Android Studio installation on
          this machine.
          To manually set the JDK path, use: `flutter config
          --jdk-dir="path/to/jdk"`.
        • Java version OpenJDK Runtime Environment (build 21.0.6+-13355223-b631.42)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 16.3) [556ms]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 16E140
        • 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 /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.6+-13355223-b631.42)
    
    [✓] VS Code (version 1.99.3) [8ms]
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension can be installed from:
          🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
    
    [✓] Connected device (3 available) [5.5s]
        • macOS (desktop)                 • macos                 • darwin-arm64   •
          macOS 15.4.1 24E263 darwin-arm64
        • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         •
          macOS 15.4.1 24E263 darwin-arm64
        • Chrome (web)                    • chrome                • web-javascript •
          Google Chrome 135.0.7049.115
    
    [✓] Network resources [559ms]
        • All expected network resources are available.
    
    • No issues found!
    
    master (3.33.0-1.0.pre.83) - flutter doctor -v
    [✓] Flutter (Channel master, 3.33.0-1.0.pre.83, on macOS 15.4.1 24E263 darwin-arm64, locale en-IN) [1,952ms]
        • Flutter version 3.33.0-1.0.pre.83 on channel master at /Users/tirthpatel/Development/flutter_master/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision eb0712fd4c (70 minutes ago), 2025-05-14 21:11:17 -0700
        • Engine revision eb0712fd4c
        • Dart version 3.9.0 (build 3.9.0-117.0.dev)
        • DevTools version 2.46.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [880ms]
        • Android SDK at /Users/tirthpatel/Library/Android/sdk
        • Emulator version 35.4.9.0 (build_id 13025442) (CL:N/A)
        • Platform android-36, build-tools 36.0.0
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
          This is the JDK bundled with the latest Android Studio installation on this machine.
          To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
        • Java version OpenJDK Runtime Environment (build 21.0.6+-13355223-b631.42)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 16.3) [620ms]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 16E140
        • CocoaPods version 1.16.2
    
    [✓] Chrome - develop for the web [8ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2024.3) [7ms]
        • Android Studio at /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.6+-13355223-b631.42)
    
    [✓] VS Code (version 1.100.0) [7ms]
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.110.0
    
    [✓] Connected device (2 available) [5.6s]
        • macOS (desktop) • macos  • darwin-arm64   • macOS 15.4.1 24E263 darwin-arm64
        • Chrome (web)    • chrome • web-javascript • Google Chrome 136.0.7103.94
    
    [✓] Network resources [864ms]
        • All expected network resources are available.
    
    • No issues found!
    
  15. added
    found in release: 3.29
    found in release: 3.33
    and removed
    found in release: 2.5
    found in release: 2.6
    on May 15, 2025
  16. added
    package
    and removed
    framework
    on Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2found in release: 3.29found in release: 3.33has reproducible stepsp: cupertino_uipackageteam-designtriaged-designworkaround available

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions