Skip to content

CupertinoNavigationBar crashes when pressing back button #73956

Closed

Description

@chunhtai

Steps to Reproduce

code
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class Page1 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      navigationBar: CupertinoNavigationBar(
        middle: Text('Page 1'),
      ),
      child: Center(
        child: TextButton(
          child: Text("Next"),
          onPressed: () {
            Navigator.of(context).push<void>(
              CupertinoPageRoute(
                builder: (BuildContext context) => Page2(),
                title: "Page 2",
              ),
            );
          },
        ),
      ),
    );
  }
}

class Page2 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      navigationBar: CupertinoNavigationBar(
        middle: Text("Page 2"),
      ),
      child: Center(
        child: Text("Page 2"),
      ),
    );
  }
}


void main() {
  runApp(CupertinoApp(home: Page1()));
}
  1. press next to go to page 2

  2. press back button on nav bar

Logs

Logs
The following assertion was thrown building CupertinoNavigationBarBackButton(dirty, dependencies:
[_ModalScopeStatus]):
CupertinoNavigationBarBackButton should only be used in routes that can be popped
'package:flutter/src/cupertino/nav_bar.dart':
Failed assertion: line 1366 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:
  CupertinoNavigationBar file:///Users/chtai/apps/test1/lib/main.dart:32:22


This is a regression introduced in #71944

Activity

  1. added
    c: regression
    framework
    p: cupertino_ui
    f: routes
    on Jan 14, 2021
  2. self-assigned this
    on Jan 14, 2021
  3. github-actions commented on Aug 7, 2021

    @github-actions

    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 -v and a minimal reproduction of the issue.

  4. locked as resolved and limited conversation to collaborators on Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

c: regressionf: routesframeworkp: cupertino_ui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions