exists function
Collection of functions that can be used in PageObjects to do simple common functions on PageLoaderElements or PageObjects without requiring a passthrough for those properties.
These functions should not be used in expect calls or where a matcher can be used. Their corresponding matchers should be used instead.
Example: @ByTagName('material-button') MaterialButtonPO get submitButton;
// Only click on the button if it exists Future submit() => exists(submitButton) ? submitButton.click() : null;
A matcher that checks if a PageLoaderElement/PageObject exists. If used on a List annotated by a Pageloader annotation, checks to see if not empty.
Implementation
/// A matcher that checks if a PageLoaderElement/PageObject exists.
/// If used on a List annotated by a Pageloader annotation, checks to see
/// if not empty.
bool exists(item) {
if (item is PageObjectList<Object>) {
return item.isNotEmpty;
}
return _rootElementOfAndRethrow(item, 'exists/notExists').exists;
}