You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the `pubspec.yaml` of your flutter project, add the following dependency:
10
+
11
+
```yaml
12
+
dependencies:
13
+
...
14
+
tf_form: ^0.0.1
15
+
```
16
+
17
+
In your library add the following import:
18
+
19
+
```dart
20
+
import 'package:tf_form/tf_form.dart';
21
+
```
22
+
23
+
## Widgets
24
+
25
+
### TFForm
26
+
27
+
The `TFForm` widget acts as a container for grouping and validating multiple form widgets provided by package. It requires a `GlobalKey` to allow validation of the form in a later step. Also, you can configure error messages or style the form by passing arguments to the constructor.
12
28
13
29
```dart
14
30
final _formKey = GlobalKey<TFFormState>();
15
31
16
32
@override
17
33
Widget build(BuildContext context) {
18
-
// Build a Form widget using the _formKey created above.
34
+
// Build a TFForm widget using the _formKey created above.
19
35
return TFForm(
20
36
key: _formKey,
21
37
child: Column(
22
38
children: <Widget>[
23
-
// Add TFTextField and ElevatedButton here.
39
+
// Add form widgets and ElevatedButton here.
24
40
],
25
41
),
26
42
);
27
43
}
28
44
```
29
-
30
-
### Add a `TFTextField` with validation types and controller
31
-
`TFTextField` maintains the current state of the form field, so that updates
32
-
and validation errors are visually reflected in the UI.
33
45
34
-
A `TFForm` ancestor is required. The `TFForm` simply makes it easier to
35
-
validate multiple fields at once.
46
+
### TFTextField
36
47
37
-
```dart
48
+
A text field is the most popular form widget. It lets the user enter text, either with hardware keyboard or with an onscreen keyboard.
49
+
50
+
```dart
38
51
TFTextField(
39
-
label: "Nickname",
52
+
title: "Nickname",
53
+
hintText: "Enter a nickname",
40
54
controller: nicknameController,
41
-
types: const [
42
-
TFTextFieldType.required,
43
-
],
44
-
),
45
-
TFTextField(
46
-
label: "Email",
47
-
controller: emailController,
48
-
types: const [
49
-
TFTextFieldType.required,
50
-
TFTextFieldType.emailAddress,
55
+
validationTypes: const [
56
+
TFValidationType.required,
51
57
],
52
58
),
53
-
TFTextField(
54
-
label: "Phone",
55
-
controller: phoneController,
56
-
types: const [
57
-
TFTextFieldType.required,
58
-
TFTextFieldType.phone,
59
+
```
60
+
61
+
### TFDropdownField
62
+
63
+
A dropdown field allows the user to pick a value from a dropdown list
0 commit comments