Skip to content

Commit 98f87d7

Browse files
authored
Merge pull request #323 from awhitford/pedantic-1.9
Pedantic 1.9
2 parents 7c8fa94 + 589a968 commit 98f87d7

21 files changed

+92
-95
lines changed

lib/src/fields/form_builder_checkbox.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ class _FormBuilderCheckboxState extends State<FormBuilderCheckbox> {
133133
? null
134134
: () {
135135
FocusScope.of(context).requestFocus(FocusNode());
136-
bool newValue = !(field.value ?? false);
136+
final newValue = !(field.value ?? false);
137137
field.didChange(newValue);
138-
if (widget.onChanged != null) widget.onChanged(newValue);
138+
widget.onChanged?.call(newValue);
139139
},
140140
),
141141
);

lib/src/fields/form_builder_checkbox_list.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ class _FormBuilderCheckboxListState extends State<FormBuilderCheckboxList> {
123123
}
124124
},
125125
builder: (FormFieldState<dynamic> field) {
126-
List<Widget> checkboxList = [];
127-
for (int i = 0; i < widget.options.length; i++) {
126+
final checkboxList = <Widget>[];
127+
for (var i = 0; i < widget.options.length; i++) {
128128
checkboxList.addAll([
129129
ListTile(
130130
dense: true,

lib/src/fields/form_builder_color_picker.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class _FormBuilderColorPickerState extends State<FormBuilderColorPicker> {
111111
final GlobalKey<FormFieldState> _fieldKey = GlobalKey<FormFieldState>();
112112
FormBuilderState _formState;
113113
Color _initialValue;
114-
FocusNode _focusNode = FocusNode();
114+
final _focusNode = FocusNode();
115115
TextEditingController _textEditingController;
116116

117117
TextEditingController get _effectiveController =>
@@ -226,7 +226,7 @@ class _FormBuilderColorPickerState extends State<FormBuilderColorPicker> {
226226
_effectiveController.text = HexColor(color)?.toHex();
227227
}
228228

229-
_handleFocus() async {
229+
Future<void> _handleFocus() async {
230230
if (effectiveFocusNode.hasFocus && !_readOnly) {
231231
await Future.microtask(
232232
() => FocusScope.of(context).requestFocus(FocusNode()));
@@ -284,7 +284,7 @@ class _FormBuilderColorPickerState extends State<FormBuilderColorPicker> {
284284
},
285285
);
286286
default:
287-
throw "Unknown ColorPickerType";
287+
throw 'Unknown ColorPickerType';
288288
}
289289
}),
290290
),

lib/src/fields/form_builder_country_picker.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ class FormBuilderCountryPicker extends StatefulWidget {
3434
FormBuilderCountryPicker({
3535
Key key,
3636
@required this.attribute,
37-
this.defaultSelectedCountryIsoCode = "US",
38-
this.initialValue,
37+
this.defaultSelectedCountryIsoCode = 'US',
38+
@required this.initialValue,
3939
this.validators = const [],
4040
this.readOnly = false,
4141
this.decoration = const InputDecoration(),
@@ -194,7 +194,7 @@ class _FormBuilderCountryPickerState extends State<FormBuilderCountryPicker> {
194194
child: ListTile(
195195
contentPadding: EdgeInsets.zero,
196196
leading: CountryPickerUtils.getDefaultFlagImage(country),
197-
title: Text("${country.name}"),
197+
title: Text(country.name),
198198
// visualDensity: VisualDensity.compact, //TODO: Re-enable after Flutter 1.17
199199
),
200200
);

lib/src/fields/form_builder_date_range_picker.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class FormBuilderDateRangePickerState
243243
);
244244
}
245245

246-
_handleFocus() async {
246+
Future<void> _handleFocus() async {
247247
if (_effectiveFocusNode.hasFocus) {
248248
_hideKeyboard();
249249
var initialFirstDate = value.isEmpty
@@ -252,7 +252,7 @@ class FormBuilderDateRangePickerState
252252
var initialLastDate = value.isEmpty
253253
? (widget.initialLastDate ?? initialFirstDate)
254254
: (value.length < 2 ? initialFirstDate : value[1]);
255-
final List<DateTime> picked = await date_range_picker.showDatePicker(
255+
final picked = await date_range_picker.showDatePicker(
256256
context: context,
257257
initialFirstDate: initialFirstDate,
258258
initialLastDate: initialLastDate,
@@ -269,16 +269,16 @@ class FormBuilderDateRangePickerState
269269
}
270270
}
271271

272-
_valueToText() {
272+
String _valueToText() {
273273
if (value.isEmpty) {
274-
return "";
274+
return '';
275275
} else if (value.length == 1) {
276-
return "${format(value[0])}";
276+
return format(value[0]);
277277
}
278-
return "${format(value[0])} - ${format(value[1])}";
278+
return '${format(value[0])} - ${format(value[1])}';
279279
}
280280

281-
_setCurrentValue(val) {
281+
void _setCurrentValue(val) {
282282
setState(() {
283283
_currentValue = val ?? [];
284284
});

lib/src/fields/form_builder_date_time_picker.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class _FormBuilderDateTimePickerState extends State<FormBuilderDateTimePicker> {
218218
final _dateTimeFormats = {
219219
InputType.both: DateFormat("EEEE, MMMM d, yyyy 'at' h:mma"),
220220
InputType.date: DateFormat('yyyy-MM-dd'),
221-
InputType.time: DateFormat("HH:mm"),
221+
InputType.time: DateFormat('HH:mm'),
222222
};
223223

224224
@override
@@ -240,7 +240,7 @@ class _FormBuilderDateTimePickerState extends State<FormBuilderDateTimePicker> {
240240
}
241241

242242
// Hack to avoid manual editing of date - as is in DateTimeField library
243-
_handleFocus() async {
243+
Future<void> _handleFocus() async {
244244
setState(() {
245245
stateCurrentValue = _fieldKey.currentState.value;
246246
});
@@ -344,7 +344,7 @@ class _FormBuilderDateTimePickerState extends State<FormBuilderDateTimePicker> {
344344
}
345345
break;
346346
default:
347-
throw "Unexcepted input type ${widget.inputType}";
347+
throw 'Unexcepted input type ${widget.inputType}';
348348
break;
349349
}
350350
newValue = newValue ?? currentValue;

lib/src/fields/form_builder_dropdown.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class _FormBuilderDropdownState extends State<FormBuilderDropdown> {
123123
.firstWhere((val) => val.value == field.value,
124124
orElse: () => null)
125125
?.child ??
126-
Text("${field.value.toString()}"))
126+
Text(field.value.toString()))
127127
: widget.disabledHint,
128128
elevation: widget.elevation,
129129
iconSize: widget.iconSize,
@@ -157,10 +157,10 @@ class _FormBuilderDropdownState extends State<FormBuilderDropdown> {
157157
);
158158
}
159159

160-
_changeValue(FormFieldState field, value) {
160+
void _changeValue(FormFieldState field, value) {
161161
FocusScope.of(context).requestFocus(FocusNode());
162162
field.didChange(value);
163-
if (widget.onChanged != null) widget.onChanged(value);
163+
widget.onChanged?.call(value);
164164
}
165165

166166
/*@override

lib/src/fields/form_builder_phone_field.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class FormBuilderPhoneField extends StatefulWidget {
107107
this.titlePadding,
108108
this.dialogTitle,
109109
this.isSearchable,
110-
this.defaultSelectedCountryIsoCode = "US",
110+
this.defaultSelectedCountryIsoCode = 'US',
111111
this.priorityListByIsoCode,
112112
this.countryFilterByIsoCode,
113113
this.dialogTextStyle,
@@ -173,7 +173,7 @@ class FormBuilderPhoneFieldState extends State<FormBuilderPhoneField> {
173173
_effectiveController.text = parseResult['national_number'];
174174
}
175175
} catch (error) {
176-
_effectiveController.text = _initialValue.replaceFirst("+", "");
176+
_effectiveController.text = _initialValue.replaceFirst('+', '');
177177
}
178178
}
179179
}
@@ -273,7 +273,7 @@ class FormBuilderPhoneFieldState extends State<FormBuilderPhoneField> {
273273
Icon(Icons.arrow_drop_down),
274274
CountryPickerUtils.getDefaultFlagImage(_selectedDialogCountry),
275275
Text(
276-
"+${_selectedDialogCountry.phoneCode} ",
276+
'+${_selectedDialogCountry.phoneCode} ',
277277
style: widget.style ?? Theme.of(context).textTheme.subtitle1,
278278
),
279279
],
@@ -359,9 +359,9 @@ class FormBuilderPhoneFieldState extends State<FormBuilderPhoneField> {
359359
child: ListTile(
360360
contentPadding: EdgeInsets.zero,
361361
leading: CountryPickerUtils.getDefaultFlagImage(country),
362-
title: Text("${country.name}"),
362+
title: Text(country.name),
363363
// visualDensity: VisualDensity.compact, //TODO: Re-enable after Flutter 1.17
364-
trailing: Text("+${country.phoneCode}"),
364+
trailing: Text('+${country.phoneCode}'),
365365
),
366366
);
367367
}

lib/src/fields/form_builder_radio.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ class _FormBuilderRadioState extends State<FormBuilderRadio> {
111111
}
112112
},
113113
builder: (FormFieldState<dynamic> field) {
114-
List<Widget> radioList = [];
115-
for (int i = 0; i < widget.options.length; i++) {
114+
final radioList = <Widget>[];
115+
for (var i = 0; i < widget.options.length; i++) {
116116
radioList.addAll([
117117
ListTile(
118118
dense: true,
@@ -124,10 +124,9 @@ class _FormBuilderRadioState extends State<FormBuilderRadio> {
124124
onTap: _readOnly
125125
? null
126126
: () {
127-
field.didChange(widget.options[i].value);
128-
if (widget.onChanged != null) {
129-
widget.onChanged(widget.options[i].value);
130-
}
127+
final value = widget.options[i].value;
128+
field.didChange(value);
129+
widget.onChanged?.call(value);
131130
},
132131
),
133132
Divider(

lib/src/fields/form_builder_range_slider.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ class _FormBuilderRangeSliderState extends State<FormBuilderRangeSlider> {
126126
Row(
127127
mainAxisAlignment: MainAxisAlignment.spaceBetween,
128128
children: <Widget>[
129-
Text("${widget.min}"),
130-
Text("${field.value.start} - ${field.value.end}"),
131-
Text("${widget.max}"),
129+
Text('${widget.min}'),
130+
Text('${field.value.start} - ${field.value.end}'),
131+
Text('${widget.max}'),
132132
],
133133
),
134134
],

0 commit comments

Comments
 (0)