Skip to content

Commit caa75d7

Browse files
authored
Const keywords (#327)
* Added const keywords.
1 parent ff89fb5 commit caa75d7

File tree

5 files changed

+49
-38
lines changed

5 files changed

+49
-38
lines changed

example/lib/main.dart

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ class MyApp extends StatelessWidget {
1616
theme: ThemeData(
1717
primarySwatch: Colors.blue,
1818
// brightness: Brightness.dark,
19-
inputDecorationTheme: InputDecorationTheme(
19+
inputDecorationTheme: const InputDecorationTheme(
2020
// labelStyle: TextStyle(color: Colors.purple),
2121
border: OutlineInputBorder(
2222
gapPadding: 10,
2323
),
24-
2524
),
2625
),
2726
home: MyHomePage(),
@@ -55,7 +54,7 @@ class MyHomePageState extends State<MyHomePage> {
5554
title: Text('FormBuilder Example'),
5655
),
5756
body: Padding(
58-
padding: EdgeInsets.all(10),
57+
padding: const EdgeInsets.all(10),
5958
child: ListView(
6059
children: <Widget>[
6160
FormBuilder(
@@ -70,7 +69,7 @@ class MyHomePageState extends State<MyHomePage> {
7069
children: <Widget>[
7170
FormBuilderFilterChip(
7271
attribute: 'filter_chip',
73-
decoration: InputDecoration(
72+
decoration: const InputDecoration(
7473
labelText: 'Select many options',
7574
),
7675
options: [
@@ -89,7 +88,7 @@ class MyHomePageState extends State<MyHomePage> {
8988
SizedBox(height: 15),
9089
FormBuilderChoiceChip(
9190
attribute: 'choice_chip',
92-
decoration: InputDecoration(
91+
decoration: const InputDecoration(
9392
labelText: 'Select an option',
9493
),
9594
options: [
@@ -111,11 +110,11 @@ class MyHomePageState extends State<MyHomePage> {
111110
attribute: 'color_picker',
112111
// initialValue: Colors.yellow,
113112
colorPickerType: ColorPickerType.SlidePicker,
114-
decoration: InputDecoration(labelText: 'Pick Color'),
113+
decoration: const InputDecoration(labelText: 'Pick Color'),
115114
),
116115
SizedBox(height: 15),
117116
FormBuilderChipsInput(
118-
decoration: InputDecoration(labelText: 'Chips'),
117+
decoration: const InputDecoration(labelText: 'Chips'),
119118
attribute: 'chips_test',
120119
onChanged: _onChanged,
121120
initialValue: [
@@ -172,7 +171,7 @@ class MyHomePageState extends State<MyHomePage> {
172171
attribute: 'date',
173172
onChanged: _onChanged,
174173
inputType: InputType.time,
175-
decoration: InputDecoration(
174+
decoration: const InputDecoration(
176175
labelText: 'Appointment Time',
177176
),
178177
validator: (val) => null,
@@ -185,10 +184,13 @@ class MyHomePageState extends State<MyHomePage> {
185184
attribute: 'date_range',
186185
firstDate: DateTime(1970),
187186
lastDate: DateTime.now(),
188-
initialValue: [DateTime.now().subtract(Duration(days: 30)), DateTime.now().subtract(Duration(seconds: 10))],
187+
initialValue: [
188+
DateTime.now().subtract(Duration(days: 30)),
189+
DateTime.now().subtract(Duration(seconds: 10))
190+
],
189191
format: DateFormat('yyyy-MM-dd'),
190192
onChanged: _onChanged,
191-
decoration: InputDecoration(
193+
decoration: const InputDecoration(
192194
labelText: 'Date Range',
193195
helperText: 'Helper text',
194196
hintText: 'Hint text',
@@ -205,7 +207,7 @@ class MyHomePageState extends State<MyHomePage> {
205207
divisions: 20,
206208
activeColor: Colors.red,
207209
inactiveColor: Colors.pink[100],
208-
decoration: InputDecoration(
210+
decoration: const InputDecoration(
209211
labelText: 'Number of things',
210212
),
211213
),
@@ -220,7 +222,7 @@ class MyHomePageState extends State<MyHomePage> {
220222
divisions: 20,
221223
activeColor: Colors.red,
222224
inactiveColor: Colors.pink[100],
223-
decoration: InputDecoration(
225+
decoration: const InputDecoration(
224226
labelText: 'Price Range',
225227
),
226228
),
@@ -261,7 +263,7 @@ class MyHomePageState extends State<MyHomePage> {
261263
),
262264
FormBuilderTextField(
263265
attribute: 'age',
264-
decoration: InputDecoration(
266+
decoration: const InputDecoration(
265267
labelText:
266268
'This value is passed along to the [Text.maxLines] attribute of the [Text] widget used to display the hint text.',
267269
),
@@ -280,7 +282,7 @@ class MyHomePageState extends State<MyHomePage> {
280282
SizedBox(height: 15),
281283
FormBuilderDropdown(
282284
attribute: 'gender',
283-
decoration: InputDecoration(
285+
decoration: const InputDecoration(
284286
labelText: 'Gender',
285287
border: UnderlineInputBorder(
286288
borderSide: BorderSide(
@@ -301,7 +303,7 @@ class MyHomePageState extends State<MyHomePage> {
301303
),
302304
SizedBox(height: 15),
303305
FormBuilderTypeAhead(
304-
decoration: InputDecoration(
306+
decoration: const InputDecoration(
305307
labelText: 'Country',
306308
),
307309
attribute: 'country',
@@ -331,7 +333,7 @@ class MyHomePageState extends State<MyHomePage> {
331333
),
332334
SizedBox(height: 15),
333335
FormBuilderTypeAhead<Contact>(
334-
decoration: InputDecoration(
336+
decoration: const InputDecoration(
335337
labelText: 'Contact Person',
336338
),
337339
initialValue: contacts[0],
@@ -380,7 +382,7 @@ class MyHomePageState extends State<MyHomePage> {
380382
),
381383
SizedBox(height: 15),
382384
/*FormBuilderRadioGroup(
383-
decoration: InputDecoration(labelText: 'Pick a number'),
385+
decoration: const InputDecoration(labelText: 'Pick a number'),
384386
attribute: 'number',
385387
readOnly: true,
386388
options: [
@@ -424,17 +426,18 @@ class MyHomePageState extends State<MyHomePage> {
424426
),
425427
SizedBox(height: 15),
426428
FormBuilderTouchSpin(
427-
decoration: InputDecoration(labelText: 'Stepper'),
429+
decoration: const InputDecoration(labelText: 'Stepper'),
428430
attribute: 'stepper',
429431
initialValue: 10,
430432
step: 1,
431433
iconSize: 48.0,
432-
addIcon: Icon(Icons.arrow_right),
433-
subtractIcon: Icon(Icons.arrow_left),
434+
addIcon: const Icon(Icons.arrow_right),
435+
subtractIcon: const Icon(Icons.arrow_left),
434436
),
435437
SizedBox(height: 15),
436438
FormBuilderRate(
437-
decoration: InputDecoration(labelText: 'Rate this form'),
439+
decoration:
440+
const InputDecoration(labelText: 'Rate this form'),
438441
attribute: 'rate',
439442
iconSize: 32.0,
440443
initialValue: 1.0,
@@ -464,7 +467,7 @@ class MyHomePageState extends State<MyHomePage> {
464467
SizedBox(height: 15),
465468
FormBuilderImagePicker(
466469
attribute: 'images',
467-
decoration: InputDecoration(
470+
decoration: const InputDecoration(
468471
labelText: 'Images',
469472
),
470473
maxImages: 3,
@@ -490,8 +493,10 @@ class MyHomePageState extends State<MyHomePage> {
490493
valueTransformer: (value) {
491494
return value.isoCode;
492495
},
493-
decoration: InputDecoration(
494-
border: OutlineInputBorder(), labelText: 'Country'),
496+
decoration: const InputDecoration(
497+
border: OutlineInputBorder(),
498+
labelText: 'Country',
499+
),
495500
validators: [
496501
FormBuilderValidators.required(
497502
errorText: 'This field required.'),
@@ -504,7 +509,7 @@ class MyHomePageState extends State<MyHomePage> {
504509
// defaultSelectedCountryIsoCode: 'KE',
505510
cursorColor: Colors.black,
506511
// style: TextStyle(color: Colors.black, fontSize: 18),
507-
decoration: InputDecoration(
512+
decoration: const InputDecoration(
508513
border: OutlineInputBorder(),
509514
labelText: 'Phone Number',
510515
),
@@ -519,7 +524,7 @@ class MyHomePageState extends State<MyHomePage> {
519524
),
520525
SizedBox(height: 15),
521526
FormBuilderSignaturePad(
522-
decoration: InputDecoration(labelText: 'Signature'),
527+
decoration: const InputDecoration(labelText: 'Signature'),
523528
attribute: 'signature',
524529
// height: 250,
525530
clearButtonText: 'Start Over',
@@ -528,11 +533,15 @@ class MyHomePageState extends State<MyHomePage> {
528533
SizedBox(height: 15),
529534
FormBuilderRadioGroup(
530535
attribute: 'radio_group',
531-
decoration: InputDecoration(labelText: 'Radio Group'),
536+
decoration: const InputDecoration(labelText: 'Radio Group'),
532537
onChanged: _onChanged,
533538
options: [
534-
FormBuilderFieldOption(value: 'Male',),
535-
FormBuilderFieldOption(value: 'Female',),
539+
FormBuilderFieldOption(
540+
value: 'Male',
541+
),
542+
FormBuilderFieldOption(
543+
value: 'Female',
544+
),
536545
],
537546
),
538547
SizedBox(height: 15),
@@ -548,8 +557,10 @@ class MyHomePageState extends State<MyHomePage> {
548557
return InputDecorator(
549558
decoration: InputDecoration(
550559
labelText: 'FormBuilderCustomField',
551-
contentPadding:
552-
EdgeInsets.only(top: 10.0, bottom: 0.0),
560+
contentPadding: const EdgeInsets.only(
561+
top: 10.0,
562+
bottom: 0.0,
563+
),
553564
border: InputBorder.none,
554565
errorText: field.errorText,
555566
),
@@ -558,7 +569,7 @@ class MyHomePageState extends State<MyHomePage> {
558569
child: CupertinoPicker(
559570
itemExtent: 30,
560571
children:
561-
allCountries.map((c) => Text(c)).toList(),
572+
allCountries.map((c) => Text(c)).toList(),
562573
onSelectedItemChanged: (index) {
563574
print(index);
564575
field.didChange(allCountries[index]);

lib/src/fields/form_builder_image_picker.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,15 @@ class _FormBuilderImagePickerState extends State<FormBuilderImagePicker> {
157157
field.didChange([...field.value]..remove(item));
158158
},
159159
child: Container(
160-
margin: EdgeInsets.all(3),
160+
margin: const EdgeInsets.all(3),
161161
decoration: BoxDecoration(
162162
color: Colors.grey.withOpacity(.7),
163163
shape: BoxShape.circle,
164164
),
165165
alignment: Alignment.center,
166166
height: 22,
167167
width: 22,
168-
child: Icon(
168+
child: const Icon(
169169
Icons.close,
170170
size: 18,
171171
color: Colors.white,

lib/src/fields/form_builder_range_slider.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class _FormBuilderRangeSliderState extends State<FormBuilderRangeSlider> {
9898
errorText: field.errorText,
9999
),
100100
child: Container(
101-
padding: EdgeInsets.only(top: 10.0),
101+
padding: const EdgeInsets.only(top: 10.0),
102102
child: Column(
103103
crossAxisAlignment: CrossAxisAlignment.start,
104104
children: [

lib/src/fields/form_builder_segmented_control.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class _FormBuilderSegmentedControlState
103103
errorText: field.errorText,
104104
),
105105
child: Padding(
106-
padding: EdgeInsets.only(top: 10.0),
106+
padding: const EdgeInsets.only(top: 10.0),
107107
child: CupertinoSegmentedControl(
108108
borderColor: _readOnly
109109
? Theme.of(context).disabledColor
@@ -119,7 +119,7 @@ class _FormBuilderSegmentedControlState
119119
widget.options,
120120
key: (option) => option.value,
121121
value: (option) => Padding(
122-
padding: EdgeInsets.symmetric(vertical: 10.0),
122+
padding: const EdgeInsets.symmetric(vertical: 10.0),
123123
// ignore: deprecated_member_use_from_same_package
124124
child: widget.textStyle != null
125125
? Text(

lib/src/fields/form_builder_slider.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class _FormBuilderSliderState extends State<FormBuilderSlider> {
104104
errorText: field.errorText,
105105
),
106106
child: Container(
107-
padding: EdgeInsets.only(top: 10.0),
107+
padding: const EdgeInsets.only(top: 10.0),
108108
child: Column(
109109
crossAxisAlignment: CrossAxisAlignment.start,
110110
children: [

0 commit comments

Comments
 (0)