TextExistsStep function
StepDefinitionGeneric<World>
TextExistsStep()
Asserts the existence of text on the screen.
Examples:
Then I expect the text "Logout" to be present
But I expect the text "Signup" to be absent
Implementation
StepDefinitionGeneric TextExistsStep() {
return then2<String, Existence, FlutterWorld>(
RegExp(r'I expect the text {string} to be {existence}$'),
(text, exists, context) async {
if (exists == Existence.present) {
final isPresent = await FlutterDriverUtils.isPresent(
context.world.driver,
find.text(text),
);
context.expect(isPresent, true);
} else {
final isAbsent = await FlutterDriverUtils.isAbsent(
context.world.driver,
find.text(text),
);
context.expect(isAbsent, true);
}
},
);
}