在进入主页前如何验证电子邮件 [英] how to validate email before enter to the home page flutter

查看:76
本文介绍了在进入主页前如何验证电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试验证我的电子邮件,然后用户才能进入主页.问题是,当我用任何东西填充电子邮件和密码用户时,它无需任何检查即可提供访问权限.这是我的登录页面代码

i'm trying to validate my email before the user can enter to the home page. the problem is when i fill the email and password user with aaany thing it give the access without any check. here is my code for sign in page

这是注册屏幕的代码

推荐答案

如果仅涉及验证电子邮件以进行格式化,那么下面将显示您可以做的事情.将其放入您要提交登录/注册

If it is all about validating the email for formatting, then what you can do is shown below. Put it in your email address validator you are submitting the data for Login/Register

validator: (value){
    Pattern pattern = r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
    RegExp regex = new RegExp(pattern);
    // Null check
    if(value.isEmpty){
        return 'please enter your email';
    }
    // Valid email formatting check
    else if(!regex.hasMatch(value)){
       return 'Enter valid email address';
    }
    // success condition
    else {
       email = value;
    }
    return null;
}

您将很高兴与此:)祝您学习愉快.

You will be good to go with this :) Happy learning.

这篇关于在进入主页前如何验证电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆