Skip to content

Commit

Permalink
Fix bug where CountryPicker still works in readOnly. Closes #413
Browse files Browse the repository at this point in the history
  • Loading branch information
danvick committed Aug 15, 2020
1 parent 8c976a2 commit 89a6274
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions lib/src/fields/form_builder_country_picker.dart
Expand Up @@ -100,14 +100,16 @@ class _FormBuilderCountryPickerState extends State<FormBuilderCountryPicker> {
},
builder: (FormFieldState<Country> field) {
return GestureDetector(
onTap: () {
FocusScope.of(context).requestFocus(FocusNode());
if (widget.isCupertinoPicker) {
_openCupertinoCountryPicker(field);
} else {
_openCountryPickerDialog(field);
}
},
onTap: _readOnly
? null
: () {
FocusScope.of(context).requestFocus(FocusNode());
if (widget.isCupertinoPicker) {
_openCupertinoCountryPicker(field);
} else {
_openCountryPickerDialog(field);
}
},
child: InputDecorator(
decoration: widget.decoration.copyWith(
errorText: field.errorText,
Expand All @@ -116,14 +118,9 @@ class _FormBuilderCountryPickerState extends State<FormBuilderCountryPicker> {
key: ObjectKey(field.value),
children: [
CountryPickerUtils.getDefaultFlagImage(field.value),
SizedBox(
width: 10,
),
SizedBox(width: 10),
Expanded(
child: Text(
field.value?.name ?? '',
style: widget.style,
),
child: Text(field.value?.name ?? '', style: widget.style),
),
],
),
Expand Down Expand Up @@ -192,8 +189,8 @@ class _FormBuilderCountryPickerState extends State<FormBuilderCountryPicker> {
child: ListTile(
contentPadding: EdgeInsets.zero,
leading: CountryPickerUtils.getDefaultFlagImage(country),
title: Text(country.name),
// visualDensity: VisualDensity.compact, //TODO: Re-enable after Flutter 1.17
title: Text('${country.name}'),
visualDensity: VisualDensity.compact,
),
);
}
Expand Down

0 comments on commit 89a6274

Please sign in to comment.