@@ -30,12 +30,13 @@ class FormBuilderCountryPicker extends StatefulWidget {
30
30
final bool isCupertinoPicker;
31
31
final double cupertinoPickerSheetHeight;
32
32
final Color cursorColor;
33
+ final String placeholderText;
33
34
34
35
FormBuilderCountryPicker ({
35
36
Key key,
36
37
@required this .attribute,
37
- this .defaultSelectedCountryIsoCode = 'US' ,
38
- @required this .initialValue,
38
+ this .defaultSelectedCountryIsoCode,
39
+ this .initialValue,
39
40
this .validators = const [],
40
41
this .readOnly = false ,
41
42
this .decoration = const InputDecoration (),
@@ -53,8 +54,8 @@ class FormBuilderCountryPicker extends StatefulWidget {
53
54
this .isCupertinoPicker = false ,
54
55
this .cupertinoPickerSheetHeight,
55
56
this .cursorColor,
56
- }) : assert (initialValue != null ) ,
57
- super (key: key);
57
+ this .placeholderText = 'Select country' ,
58
+ }) : super (key: key);
58
59
59
60
@override
60
61
_FormBuilderCountryPickerState createState () =>
@@ -117,10 +118,14 @@ class _FormBuilderCountryPickerState extends State<FormBuilderCountryPicker> {
117
118
child: Row (
118
119
key: ObjectKey (field.value),
119
120
children: [
120
- CountryPickerUtils .getDefaultFlagImage (field.value),
121
+ if (field.value != null )
122
+ CountryPickerUtils .getDefaultFlagImage (field.value),
121
123
SizedBox (width: 10 ),
122
124
Expanded (
123
- child: Text (field.value? .name ?? '' , style: widget.style),
125
+ child: Text (
126
+ field.value? .name ?? widget.placeholderText ?? '' ,
127
+ style: widget.style,
128
+ ),
124
129
),
125
130
],
126
131
),
0 commit comments