Skip to content

PopScope breaks willHandlePopInternally and didpop #134752

Closed

Description

@chunhtai

Is there an existing issue for this?

Steps to reproduce

Run the test

Expected results

test passes.

Actual results

The test fails, which means willHandlePopInternally return true but didPop also return true. According to the doc https://api.flutter.dev/flutter/widgets/Route/willHandlePopInternally.html, the willHandlePopInternally should return the inverse of didpop.

Code sample

Code sample
testWidgets('ModalRoute must comply with willHandlePopInternally when there is a PopScope', (WidgetTester tester) async {
      const List<Page<void>> myPages = <Page<void>>[
        MaterialPage<void>(child: Text('page1')),
        MaterialPage<void>(
          child: PopScope(
            canPop: false,
            child: Text('page2'),
          ),
        ),
      ];
      await tester.pumpWidget(
        MediaQuery(
          data: MediaQueryData.fromView(tester.view),
          child: Localizations(
            locale: const Locale('en', 'US'),
            delegates: const <LocalizationsDelegate<dynamic>>[
              DefaultMaterialLocalizations.delegate,
              DefaultWidgetsLocalizations.delegate,
            ],
            child: Navigator(
              pages: myPages,
              onPopPage: (_, __) => false,
            ),
          ),
        ),
      );
      final ModalRoute<void> route = ModalRoute.of(tester.element(find.text('page2')))!;
      expect(route.willHandlePopInternally, true);
      expect(route.didPop(null), false);
    });

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]

Activity

  1. added
    f: routesNavigator, Router, and related APIs.
    P2Important issues not at the top of the work list
    on Sep 14, 2023
  2. self-assigned this
    on Sep 14, 2023
  3. chunhtai commented on Sep 14, 2023

    @chunhtai
    ContributorAuthor
  4. github-actions commented on Sep 28, 2023

    @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.

  5. locked as resolved and limited conversation to collaborators on Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listf: routesNavigator, Router, and related APIs.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions