Skip to content

Commit 4701541

Browse files
committed
Type FormBuilderDropdown class. Closes #360
1 parent 8541f82 commit 4701541

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/src/fields/form_builder_dropdown.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ import 'package:flutter/material.dart';
22
import 'package:flutter/widgets.dart';
33
import 'package:flutter_form_builder/flutter_form_builder.dart';
44

5-
class FormBuilderDropdown extends StatefulWidget {
5+
class FormBuilderDropdown<T> extends StatefulWidget {
66
final String attribute;
7-
final List<FormFieldValidator> validators;
8-
final dynamic initialValue;
7+
final List<FormFieldValidator<T>> validators;
8+
final T initialValue;
99
final bool readOnly;
1010
final InputDecoration decoration;
1111
final ValueChanged onChanged;
1212
final ValueTransformer valueTransformer;
1313

1414
final Widget hint;
15-
final List<DropdownMenuItem> items;
15+
final List<DropdownMenuItem<T>> items;
1616
final bool isExpanded;
1717
final TextStyle style;
1818
final bool isDense;
@@ -25,7 +25,7 @@ class FormBuilderDropdown extends StatefulWidget {
2525
final Color iconEnabledColor;
2626
final bool allowClear;
2727
final Widget clearIcon;
28-
final FormFieldSetter onSaved;
28+
final FormFieldSetter<T> onSaved;
2929
final double itemHeight;
3030
final Color focusColor;
3131
final Color dropdownColor;
@@ -68,14 +68,14 @@ class FormBuilderDropdown extends StatefulWidget {
6868
}) : super(key: key) /*: assert(allowClear == true || clearIcon != null)*/;
6969

7070
@override
71-
_FormBuilderDropdownState createState() => _FormBuilderDropdownState();
71+
_FormBuilderDropdownState<T> createState() => _FormBuilderDropdownState();
7272
}
7373

74-
class _FormBuilderDropdownState extends State<FormBuilderDropdown> {
74+
class _FormBuilderDropdownState<T> extends State<FormBuilderDropdown<T>> {
7575
bool _readOnly = false;
7676
final GlobalKey<FormFieldState> _fieldKey = GlobalKey<FormFieldState>();
7777
FormBuilderState _formState;
78-
dynamic _initialValue;
78+
T _initialValue;
7979

8080
@override
8181
void initState() {
@@ -116,7 +116,7 @@ class _FormBuilderDropdownState extends State<FormBuilderDropdown> {
116116
widget.onSaved(transformed ?? val);
117117
}
118118
},
119-
builder: (FormFieldState<dynamic> field) {
119+
builder: (FormFieldState<T> field) {
120120
return InputDecorator(
121121
decoration: widget.decoration.copyWith(
122122
errorText: field.errorText,
@@ -127,7 +127,7 @@ class _FormBuilderDropdownState extends State<FormBuilderDropdown> {
127127
mainAxisAlignment: MainAxisAlignment.start,
128128
children: <Widget>[
129129
Expanded(
130-
child: DropdownButton(
130+
child: DropdownButton<T>(
131131
isExpanded: widget.isExpanded,
132132
hint: widget.hint,
133133
items: widget.items,

0 commit comments

Comments
 (0)