Skip to content

Make CupertinoNavigationBarBackButton correctly return an assert error#30815

Merged
xster merged 3 commits intoflutter:masterfrom
xster:back-button-assert
Apr 15, 2019
Merged

Make CupertinoNavigationBarBackButton correctly return an assert error#30815
xster merged 3 commits intoflutter:masterfrom
xster:back-button-assert

Conversation

@xster
Copy link
Member

@xster xster commented Apr 9, 2019

Description

Fixes an the error that failed to show correctly in https://stackoverflow.com/questions/55486698/in-cupertinonavigationbar-how-do-i-show-a-button-besides-back-button-in-leading

Tests

I added the following tests:

Replace this with a list of the tests that you added as part of this PR. A change in behaviour with no test covering it
will likely get reverted accidentally sooner or later. PRs must include tests for all changed/updated/fixed behaviors. See Test Coverage.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

expect(SystemChrome.latestStyle, SystemUiOverlayStyle.dark);
});

testWidgets('Back button shows an error when manually added outside a route', (WidgetTester tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be helpful to explicitly refer to CupertinoNavigationBarBackButton in the test title to make it clear that we're talking about the use of a specific widget, rather than an incidental scenario where some kind of back button appears in the wrong place. E.g., "Exception thrown when CupertinoNavigationBarBackButton is declared outside of a Route."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, given the cause of this issue, should there also be a test where the back button widget is used in a route, but it's a route that can't be popped?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya, good point. Added


final dynamic exception = tester.takeException();
expect(exception, isAssertionError);
expect(exception.toString(), contains('can be popped'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind matching the exact text of the error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@goderbauer goderbauer added the f: cupertino flutter/packages/flutter/cupertino repository label Apr 9, 2019
@xster xster merged commit 364d73c into flutter:master Apr 15, 2019
@xster xster deleted the back-button-assert branch April 15, 2019 22:33
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

f: cupertino flutter/packages/flutter/cupertino repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants