flutter_form_field_validator

4768 단어 flutterflutter

form_field_validator

  1. pub.dev site에서 form_field_validator 검색 및 pubspec.yaml 에 install 합니다.

This report is effective as of MAY 21, 2021.

dependencies:
  form_field_validator: ^1.1.0
  1. pub get
  2. as below
    import 'package:form_field_validator/form_field_validator.dart';
        <省略>
    final formKey = GlobalKey<FormState>();
        <省略>
    TextFormField(
      validator: RequiredValidator(errorText: "fill in"),                
    ),
        <省略>
    onPressed: () {
     if (formKey.currentState.validate()) { formKey.currentState.save();
    print("확인 = ~~);
    }
  1. Email Validator 부분은 아래처럼 변경하면 빈칸일때와 형식에 맞는 지 확인할 수 있습니다.

as below example

validator: MultiValidator([
 EmailValidator(errorText: "이메일 형식에 맞질 않습니다."),
 RequiredValidator(errorText: "이메일을 입력하세요")
]),

cf. keyboardType: TextInputType.emailAddress


End
⊙^⊙ Thank For Reading | Happy Coding ⊙-⊙


Setapp on Mac invite link flutterkage2k

The referrer gets a free month, up to a maximum of six months, for each friend who creates an account and signs in on their Mac.


도움이 되셨다면, 커피 한잔 사주세요.

좋은 웹페이지 즐겨찾기