Skip to content

feat: support icon finders in tests#283

Merged
michaelspiss merged 2 commits into
fluttercommunity:masterfrom
adil192:feat/fa-icon-finder
Oct 18, 2025
Merged

feat: support icon finders in tests#283
michaelspiss merged 2 commits into
fluttercommunity:masterfrom
adil192:feat/fa-icon-finder

Conversation

@adil192

@adil192 adil192 commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

Closes #198

The find.byIcon and find.widgetByIcon use this finder internally:

class _IconWidgetFinder extends MatchFinder {
  _IconWidgetFinder(this.icon, {super.skipOffstage});

  final IconData icon;

  @override
  String get description => 'icon "$icon"';

  @override
  bool matches(Element candidate) {
    final Widget widget = candidate.widget;
    return widget is Icon && widget.icon == icon;
  }
}

This PR makes FaIcon extend Icon, reducing unnecessary code and allowing those finders to work.

Flutter test matchers expect an `Icon` type, so this satisfies that assumption while preserving the non-square aspect ratio.

Reimplementing the finders is slightly more work and would be more confusing for consumers of the package imo.
@michaelspiss

Copy link
Copy Markdown
Collaborator

This is awesome on so many levels and something we probably should have done earlier. Thank you so much @adil192!

@michaelspiss michaelspiss merged commit 8a6dc47 into fluttercommunity:master Oct 18, 2025
@adil192 adil192 deleted the feat/fa-icon-finder branch October 18, 2025 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default finders from flutter_test don't work with FaIcon

2 participants