sendVerificationEmail method

Future<void> sendVerificationEmail(
  1. TargetPlatform platform,
  2. ActionCodeSettings? actionCodeSettings
)

Implementation

Future<void> sendVerificationEmail(
  TargetPlatform platform,
  ActionCodeSettings? actionCodeSettings,
) async {
  value = EmailVerificationState.sending;
  try {
    await user.sendEmailVerification(actionCodeSettings);
  } on Exception catch (e) {
    error = e;
    value = EmailVerificationState.failed;
    return;
  }

  if (_isMobile(platform)) {
    value = EmailVerificationState.pending;
    final linkData = await FirebaseDynamicLinks.instance.onLink.first;

    try {
      final code = linkData.link.queryParameters['oobCode']!;
      await auth.checkActionCode(code);
      await auth.applyActionCode(code);
      await user.reload();
      value = EmailVerificationState.verified;
    } on Exception catch (err) {
      error = err;
      value = EmailVerificationState.failed;
    }
  } else {
    value = EmailVerificationState.sent;
  }
}