Chuyển đến nội dung chính

Bài đăng

Hiển thị các bài đăng có nhãn Validation

Form trong Flutter vượt khỏi ví dụ mẫu: validate bất đồng bộ, focus và autofill

Bài cookbook về form của Flutter đưa bạn tới một màn hình đăng ký chạy được trong khoảng bốn mươi dòng. Rồi một designer nhìn vào, và bạn phát hiện lỗi hiện đỏ trước khi ai kịp gõ chữ nào, phím Enter chẳng làm gì, trình quản lý mật khẩu phớt lờ các ô, và trên điện thoại nhỏ thì bàn phím che mất đúng ô bạn đang sửa. Không cái nào trong đó là vấn đề validate. Chúng là những phần của “một form” mà bài hướng dẫn không mô hình hóa. Ba đối tượng, và mỗi cái sở hữu gì Form là một bộ điều phối, không phải một layout. Nó giữ một FormState có thể validate() , save() và reset() mọi FormField nằm bên dưới nó trong cây. FormField sở hữu một giá trị, chuỗi lỗi của nó, và việc nó đã bị chạm tới hay chưa. TextFormField là một FormField bọc quanh một TextField . final _formKey = GlobalKey < FormState >(); Form ( key : _formKey, child : Column (children : [ TextFormField ( decoration : const InputDecoration (labelText : 'Email' ), validator : ...

Form trong Flutter vượt khỏi ví dụ mẫu: validate bất đồng bộ, focus và autofill

Bài cookbook về form của Flutter đưa bạn tới một màn hình đăng ký chạy được trong khoảng bốn mươi dòng. Rồi một designer nhìn vào, và bạn phát hiện lỗi hiện đỏ trước khi ai kịp gõ chữ nào, phím Enter chẳng làm gì, trình quản lý mật khẩu phớt lờ các ô, và trên điện thoại nhỏ thì bàn phím che mất đúng ô bạn đang sửa. Không cái nào trong đó là vấn đề validate. Chúng là những phần của “một form” mà bài hướng dẫn không mô hình hóa. Ba đối tượng, và mỗi cái sở hữu gì Form là một bộ điều phối, không phải một layout. Nó giữ một FormState có thể validate() , save() và reset() mọi FormField nằm bên dưới nó trong cây. FormField sở hữu một giá trị, chuỗi lỗi của nó, và việc nó đã bị chạm tới hay chưa. TextFormField là một FormField bọc quanh một TextField . final _formKey = GlobalKey < FormState >(); Form ( key : _formKey, child : Column (children : [ TextFormField ( decoration : const InputDecoration (labelText : 'Email' ), validator : ...

Flutter forms past the toy example: async validation, focus, and autofill

The Flutter form cookbook gets you to a working sign-up screen in about forty lines. Then a designer looks at it and you discover that the errors flash before anyone has typed, the Enter key does nothing, the password manager ignores the fields, and on a small phone the keyboard covers the field you are editing. None of those are validation problems. They are the parts of “a form” that the tutorial does not model. The three objects, and what each owns Form is a coordinator, not a layout. It holds a FormState that can validate() , save() and reset() every FormField beneath it in the tree. FormField owns one value, its error string, and whether it has been touched. TextFormField is a FormField wrapped around a TextField . final _formKey = GlobalKey < FormState >(); Form ( key : _formKey, child : Column (children : [ TextFormField ( decoration : const InputDecoration (labelText : 'Email' ), validator : (value) => (...

Flutter forms past the toy example: async validation, focus, and autofill

The Flutter form cookbook gets you to a working sign-up screen in about forty lines. Then a designer looks at it and you discover that the errors flash before anyone has typed, the Enter key does nothing, the password manager ignores the fields, and on a small phone the keyboard covers the field you are editing. None of those are validation problems. They are the parts of “a form” that the tutorial does not model. The three objects, and what each owns Form is a coordinator, not a layout. It holds a FormState that can validate() , save() and reset() every FormField beneath it in the tree. FormField owns one value, its error string, and whether it has been touched. TextFormField is a FormField wrapped around a TextField . final _formKey = GlobalKey < FormState >(); Form ( key : _formKey, child : Column (children : [ TextFormField ( decoration : const InputDecoration (labelText : 'Email' ), validator : (value) => (...