Skip to content

Commit c27f22c

Browse files
committed
Added support for Flutter v1.20
1 parent 4fccb66 commit c27f22c

10 files changed

+115
-35
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## [3.13.0] - 06-Aug-2020
2+
* Added support for Flutter v1.20
3+
14
## [3.12.3] - 05-Aug-2020
25
* Fixed bug in parsing phone number from `FormBuilderPhoneField`'s `initialValue`
36
* Added more TextField options: `toolbarOptions`, `smartQuotesType`, `smartDashesType`, `scrollPhysics`, `enableSuggestions`

lib/src/fields/form_builder_checkbox.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter/rendering.dart';
23
import 'package:flutter/widgets.dart';
34
import 'package:flutter_form_builder/flutter_form_builder.dart';
45

@@ -20,6 +21,12 @@ class FormBuilderCheckbox extends StatefulWidget {
2021
final bool tristate;
2122
final FormFieldSetter onSaved;
2223
final EdgeInsets contentPadding;
24+
final Color focusColor;
25+
final Color hoverColor;
26+
final FocusNode focusNode;
27+
final bool autoFocus;
28+
final MouseCursor mouseCursor;
29+
final VisualDensity visualDensity;
2330

2431
FormBuilderCheckbox({
2532
Key key,
@@ -38,6 +45,12 @@ class FormBuilderCheckbox extends StatefulWidget {
3845
this.tristate = false,
3946
this.onSaved,
4047
this.contentPadding = const EdgeInsets.all(0.0),
48+
this.focusColor,
49+
this.hoverColor,
50+
this.focusNode,
51+
this.autoFocus = false,
52+
this.mouseCursor,
53+
this.visualDensity,
4154
}) : super(key: key);
4255

4356
@override
@@ -81,6 +94,12 @@ class _FormBuilderCheckboxState extends State<FormBuilderCheckbox> {
8194
field.didChange(value);
8295
widget.onChanged?.call(value);
8396
},
97+
focusColor: widget.focusColor,
98+
hoverColor: widget.hoverColor,
99+
focusNode: widget.focusNode,
100+
autofocus: widget.autoFocus,
101+
mouseCursor: widget.mouseCursor,
102+
visualDensity: widget.visualDensity,
84103
);
85104
}
86105

lib/src/fields/form_builder_date_time_picker.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class FormBuilderDateTimePicker extends StatefulWidget {
3939

4040
/// The latest choosable date. Defaults to 2100.
4141
final DateTime lastDate;
42+
final DateTime currentDate;
4243

4344
/// The initial time prefilled in the picker dialog when it is shown. Defaults
4445
/// to noon. Explicitly set this to `null` to use the current time.
@@ -147,6 +148,7 @@ class FormBuilderDateTimePicker extends StatefulWidget {
147148
final String fieldLabelText;
148149
final String helpText;
149150
final DatePickerEntryMode initialEntryMode;
151+
final TimePickerEntryMode timePickerInitialEntryMode;
150152

151153
FormBuilderDateTimePicker({
152154
Key key,
@@ -214,6 +216,8 @@ class FormBuilderDateTimePicker extends StatefulWidget {
214216
this.fieldLabelText,
215217
this.helpText,
216218
this.initialEntryMode = DatePickerEntryMode.calendar,
219+
this.currentDate,
220+
this.timePickerInitialEntryMode,
217221
}) : super(key: key);
218222

219223
final StrutStyle strutStyle;
@@ -360,7 +364,7 @@ class _FormBuilderDateTimePickerState extends State<FormBuilderDateTimePicker> {
360364
}
361365
break;
362366
default:
363-
throw 'Unexcepted input type ${widget.inputType}';
367+
throw 'Unexpected input type ${widget.inputType}';
364368
break;
365369
}
366370
newValue = newValue ?? currentValue;
@@ -393,6 +397,7 @@ class _FormBuilderDateTimePickerState extends State<FormBuilderDateTimePicker> {
393397
fieldLabelText: widget.fieldLabelText,
394398
helpText: widget.helpText,
395399
initialEntryMode: widget.initialEntryMode,
400+
currentDate: widget.currentDate,
396401
builder: widget.builder ??
397402
(BuildContext context, Widget child) {
398403
return MediaQuery(
@@ -425,6 +430,10 @@ class _FormBuilderDateTimePickerState extends State<FormBuilderDateTimePicker> {
425430
},
426431
useRootNavigator: widget.useRootNavigator,
427432
routeSettings: widget.routeSettings,
433+
initialEntryMode: widget.timePickerInitialEntryMode,
434+
helpText: widget.helpText,
435+
confirmText: widget.confirmText,
436+
cancelText: widget.cancelText,
428437
).then(
429438
(result) {
430439
return result ??

lib/src/fields/form_builder_dropdown.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class FormBuilderDropdown<T> extends StatefulWidget {
3131
final Color focusColor;
3232
final Color dropdownColor;
3333
final bool autofocus;
34+
final bool autovalidate;
3435
final FocusNode focusNode;
3536
final VoidCallback onTap;
3637
final List<Widget> Function(BuildContext) selectedItemBuilder;
@@ -63,6 +64,7 @@ class FormBuilderDropdown<T> extends StatefulWidget {
6364
this.focusColor,
6465
this.dropdownColor,
6566
this.autofocus = false,
67+
this.autovalidate = false,
6668
this.focusNode,
6769
this.onTap,
6870
this.selectedItemBuilder,
@@ -100,6 +102,7 @@ class _FormBuilderDropdownState<T> extends State<FormBuilderDropdown<T>> {
100102
_readOnly = _formState?.readOnly == true || widget.readOnly;
101103

102104
return FormField(
105+
autovalidate: widget.autovalidate,
103106
key: _fieldKey,
104107
enabled: !_readOnly,
105108
initialValue: _initialValue,

lib/src/fields/form_builder_segmented_control.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class _FormBuilderSegmentedControlState
7777
@override
7878
Widget build(BuildContext context) {
7979
_readOnly = _formState?.readOnly == true || widget.readOnly;
80+
final theme = Theme.of(context);
8081

8182
return FormField(
8283
key: _fieldKey,
@@ -104,14 +105,14 @@ class _FormBuilderSegmentedControlState
104105
padding: const EdgeInsets.only(top: 10.0),
105106
child: CupertinoSegmentedControl(
106107
borderColor: _readOnly
107-
? Theme.of(context).disabledColor
108-
: widget.borderColor ?? Theme.of(context).primaryColor,
108+
? theme.disabledColor
109+
: widget.borderColor ?? theme.primaryColor,
109110
selectedColor: _readOnly
110-
? Theme.of(context).disabledColor
111-
: widget.selectedColor ?? Theme.of(context).primaryColor,
111+
? theme.disabledColor
112+
: widget.selectedColor ?? theme.primaryColor,
112113
pressedColor: _readOnly
113-
? Theme.of(context).disabledColor
114-
: widget.pressedColor ?? Theme.of(context).primaryColor,
114+
? theme.disabledColor
115+
: widget.pressedColor ?? theme.primaryColor,
115116
groupValue: field.value,
116117
children: {
117118
for (var option in widget.options)

lib/src/fields/form_builder_slider.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter/rendering.dart';
23
import 'package:flutter/widgets.dart';
34
import 'package:flutter_form_builder/flutter_form_builder.dart';
45
import 'package:intl/intl.dart';
@@ -30,6 +31,9 @@ class FormBuilderSlider extends StatefulWidget {
3031
final TextStyle minTextStyle;
3132
final TextStyle textStyle;
3233
final TextStyle maxTextStyle;
34+
final FocusNode focusNode;
35+
final bool autofocus;
36+
final MouseCursor mouseCursor;
3337

3438
FormBuilderSlider({
3539
Key key,
@@ -55,6 +59,9 @@ class FormBuilderSlider extends StatefulWidget {
5559
this.minTextStyle,
5660
this.textStyle = const TextStyle(),
5761
this.maxTextStyle,
62+
this.focusNode,
63+
this.autofocus = false,
64+
this.mouseCursor,
5865
}) : super(key: key);
5966

6067
@override
@@ -128,6 +135,9 @@ class _FormBuilderSliderState extends State<FormBuilderSlider> {
128135
onChangeStart: widget.onChangeStart,
129136
label: widget.label,
130137
semanticFormatterCallback: widget.semanticFormatterCallback,
138+
focusNode: widget.focusNode,
139+
autofocus: widget.autofocus,
140+
mouseCursor: widget.mouseCursor,
131141
onChanged: _readOnly
132142
? null
133143
: (double value) {

lib/src/fields/form_builder_switch.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/gestures.dart';
22
import 'package:flutter/material.dart';
3+
import 'package:flutter/rendering.dart';
34
import 'package:flutter/widgets.dart';
45
import 'package:flutter_form_builder/flutter_form_builder.dart';
56

@@ -63,6 +64,13 @@ class FormBuilderSwitch extends StatefulWidget {
6364
final DragStartBehavior dragStartBehavior;
6465
final FormFieldSetter onSaved;
6566
final EdgeInsets contentPadding;
67+
final MouseCursor mouseCursor;
68+
final bool autofocus;
69+
final FocusNode focusNode;
70+
final Color hoverColor;
71+
final Color focusColor;
72+
final ImageErrorListener onActiveThumbImageError;
73+
final ImageErrorListener onInactiveThumbImageError;
6674

6775
FormBuilderSwitch({
6876
Key key,
@@ -84,6 +92,13 @@ class FormBuilderSwitch extends StatefulWidget {
8492
this.dragStartBehavior = DragStartBehavior.start,
8593
this.onSaved,
8694
this.contentPadding = const EdgeInsets.all(0.0),
95+
this.mouseCursor,
96+
this.autofocus = false,
97+
this.focusNode,
98+
this.hoverColor,
99+
this.focusColor,
100+
this.onActiveThumbImageError,
101+
this.onInactiveThumbImageError,
87102
}) : super(key: key);
88103

89104
@override
@@ -161,6 +176,13 @@ class _FormBuilderSwitchState extends State<FormBuilderSwitch> {
161176
inactiveThumbImage: widget.activeThumbImage,
162177
inactiveTrackColor: widget.inactiveTrackColor,
163178
materialTapTargetSize: widget.materialTapTargetSize,
179+
mouseCursor: widget.mouseCursor,
180+
autofocus: widget.autofocus,
181+
focusNode: widget.focusNode,
182+
hoverColor: widget.hoverColor,
183+
focusColor: widget.focusColor,
184+
onActiveThumbImageError: widget.onActiveThumbImageError,
185+
onInactiveThumbImageError: widget.onInactiveThumbImageError,
164186
),
165187
onTap: _readOnly
166188
? null

lib/src/fields/form_builder_text_field.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class FormBuilderTextField extends StatefulWidget {
5151
final SmartDashesType smartDashesType;
5252
final ScrollPhysics scrollPhysics;
5353
final bool enableSuggestions;
54+
final Iterable<String> autofillHints;
55+
final String obscuringCharacter;
5456

5557
FormBuilderTextField({
5658
Key key,
@@ -60,7 +62,7 @@ class FormBuilderTextField extends StatefulWidget {
6062
this.readOnly = false,
6163
this.decoration = const InputDecoration(),
6264
this.autovalidate = false,
63-
this.maxLines,
65+
this.maxLines = 1,
6466
this.obscureText = false,
6567
this.textCapitalization = TextCapitalization.none,
6668
this.scrollPadding = const EdgeInsets.all(20.0),
@@ -99,6 +101,8 @@ class FormBuilderTextField extends StatefulWidget {
99101
this.smartDashesType,
100102
this.scrollPhysics,
101103
this.enableSuggestions = true,
104+
this.autofillHints,
105+
this.obscuringCharacter = '•',
102106
}) : assert(initialValue == null || controller == null),
103107
super(key: key);
104108

@@ -192,6 +196,8 @@ class FormBuilderTextFieldState extends State<FormBuilderTextField> {
192196
minLines: widget.minLines,
193197
showCursor: widget.showCursor,
194198
onTap: widget.onTap,
199+
autofillHints: widget.autofillHints,
200+
obscuringCharacter: widget.obscuringCharacter,
195201
);
196202
}
197203

0 commit comments

Comments
 (0)