Flutter TextFormField 邮箱验证。


引用三方包

1
2
dependencies:
  email_validator: '^1.0.0'

使用

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
import 'package:email_validator/email_validator.dart';

...

Form(
  autovalidate: true,
  child: TextFormField(
    validator: (value) => EmailValidator.validate(value) ? null : "Please enter a valid email",
  ),
)