WaitUntilKeyExistsStep function

StepDefinitionGeneric<World> WaitUntilKeyExistsStep ()

Waits until a widget is present or absent.

Examples:

Then I wait until the "login_loading_indicator" is absent And I wait until the "login_screen" is present

Implementation

StepDefinitionGeneric WaitUntilKeyExistsStep() {
  return then2<String, Existence, FlutterWorld>(
    'I wait until the {string} is {existence}',
    (keyString, existence, context) async {
      await FlutterDriverUtils.waitUntil(
        context.world.driver,
        () {
          return existence == Existence.absent
              ? FlutterDriverUtils.isAbsent(
                  context.world.driver,
                  find.byValueKey(keyString),
                )
              : FlutterDriverUtils.isPresent(
                  context.world.driver,
                  find.byValueKey(keyString),
                );
        },
      );
    },
  );
}