From bb07841a701384caa505a6a04e3dc2e73a77fdae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20=C5=9Awi=C4=99tnicki?= Date: Wed, 1 Oct 2025 07:36:19 +0200 Subject: [PATCH] Update description in _LastFinderMixin to properly describe finding last (#174232) *Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.* *List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.* *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --------- Co-authored-by: Tong Mu --- packages/flutter_test/lib/src/finders.dart | 2 +- packages/flutter_test/test/finders_test.dart | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/flutter_test/lib/src/finders.dart b/packages/flutter_test/lib/src/finders.dart index 8ec1c8b9c2d..be9c9df3e98 100644 --- a/packages/flutter_test/lib/src/finders.dart +++ b/packages/flutter_test/lib/src/finders.dart @@ -1351,7 +1351,7 @@ class _FirstWidgetFinder extends ChainedFinder with _FirstFinderMixin { mixin _LastFinderMixin on ChainedFinderMixin { @override String describeMatch(Plurality plurality) { - return '${parent.describeMatch(plurality)} (ignoring all but first)'; + return '${parent.describeMatch(plurality)} (ignoring all but last)'; } @override diff --git a/packages/flutter_test/test/finders_test.dart b/packages/flutter_test/test/finders_test.dart index ff7c61f9626..280a95d9cfd 100644 --- a/packages/flutter_test/test/finders_test.dart +++ b/packages/flutter_test/test/finders_test.dart @@ -1655,6 +1655,18 @@ void main() { expect(finder.found, orderedEquals(expected)); }); }); + + group('first and last', () { + test('describes first correctly', () { + final _FakeFinder finder = _FakeFinder(); + expect(finder.first.toString(describeSelf: true), contains('(ignoring all but first)')); + }); + + test('describes last correctly', () { + final _FakeFinder finder = _FakeFinder(); + expect(finder.last.toString(describeSelf: true), contains('(ignoring all but last)')); + }); + }); }); }