Skip to content

Conversation

@creativecreatorormaybenot
Copy link
Contributor

@creativecreatorormaybenot creativecreatorormaybenot commented Jul 28, 2021

Description

Adds support for matching standalone RichText widgets to find.text() in a backwards-compatible manner. That is, this does not break any existing tests (which #21964 did).

It adds the arguably better strategy for matching Text widgets (using only RichText) behind a skipRichText flag that has to be set to false.

Documentation

I have added both extensive additions to the existing find.text() docs as well as a comment to explain why we are using the inferior widget is Text method of looking up Text widgets (when we could just always only look for RichText as that is also inserted by Text widgets).

Tests

I have added test cases for every possible scenario, which ensures that both the new skipRichText: false strategy finds every text widget once, as well as testing that the old strategy does not match RichText at all.
The semantics test case is taken from #21964.

Issues

This resolves a popular issue:

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@google-cla google-cla bot added the cla: yes label Jul 28, 2021
@creativecreatorormaybenot
Copy link
Contributor Author

cc @mehmetf @jonahwilliams

@flutter-dashboard flutter-dashboard bot added a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. labels Jul 28, 2021
@creativecreatorormaybenot
Copy link
Contributor Author

Hi @goderbauer - I addressed all of your concerns. Can you review again? :)

/// [Text] and [Text.rich] widgets) are matched by comparing the
/// [InlineSpan.toPlainText] with the given `text`.
/// If `skipRichText` is enabled, all standalone [RichText] widgets are
/// ignored and [Text] matching shortcuts to [Text.data].
Copy link
Member

Choose a reason for hiding this comment

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

This sounds confusing, maybe better:

Suggested change
/// ignored and [Text] matching shortcuts to [Text.data].
/// ignored and `text` is matched with [Text.data].

@creativecreatorormaybenot
Copy link
Contributor Author

@goderbauer I addressed your comments from code review.

@goderbauer
Copy link
Member

Looks the analyzer is unhappy and some tests are failing. Can you take a look?

@creativecreatorormaybenot
Copy link
Contributor Author

@goderbauer Thanks - I cannot believe I missed that; updated it.

@Piinks Piinks added the c: new feature Nothing broken; request for a new capability label Aug 17, 2021
Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM after nits are fixed.

@creativecreatorormaybenot
Copy link
Contributor Author

@goderbauer done 👍

@dnfield dnfield merged commit 87b17c8 into flutter:master Aug 23, 2021
@creativecreatorormaybenot
Copy link
Contributor Author

@dnfield thx a lot ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: tests "flutter test", flutter_test, or one of our tests c: new feature Nothing broken; request for a new capability framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support RichText in finders

5 participants