bySemanticsIdentifier method
Finds Semantics widgets matching the given identifier
, either by
RegExp.hasMatch or string equality.
This allows matching against the identifier of a Semantics widget, which is a unique identifier for the widget in the semantics tree. This is exposed to offer a unified way widget tests and e2e tests can match against a Semantics widget.
Sample code
expect(find.bySemanticsIdentifier('Back'), findsOneWidget);
If the skipOffstage
argument is true (the default), then this skips
nodes that are Offstage or that are from inactive Routes.
Implementation
Finder bySemanticsIdentifier(Pattern identifier, {bool skipOffstage = true}) {
return _bySemanticsProperty(
identifier,
(SemanticsNode? semantics) => semantics?.identifier,
skipOffstage: skipOffstage,
);
}