Flutter

Forms & Validation

Form, TextFormField, GlobalKey<FormState>, validators, focus management, input types

20 câu hỏi phỏng vấn·
Mid-Level
1

What is the main role of the Form widget in Flutter?

Câu trả lời

The Form widget serves as a container to group and manage multiple form fields (FormField). It allows validating, saving, and resetting all fields in a single operation via FormState. Without Form, each field would need to be managed individually.

2

How to access FormState to trigger form validation?

Câu trả lời

To access FormState, a GlobalKey<FormState> must be assigned to the Form's key property. Then, the currentState property of this key provides access to FormState and its methods validate(), save(), and reset().

3

What is the difference between TextField and TextFormField?

Câu trả lời

TextFormField is a version of TextField integrated with Form. It inherits from FormField and has a validator property that automatically integrates with FormState.validate(). TextField cannot directly participate in grouped Form validation.

4

What does the validator property of a TextFormField return to indicate an error?

5

What is the purpose of the autovalidateMode property of a Form?

+17 câu hỏi phỏng vấn

Nắm vững Flutter cho lần phỏng vấn tiếp theo

Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.

Bắt đầu miễn phí