Skip to content

Commit 2ea948c

Browse files
committed
Set max number of chips in chipsInput field
1 parent 785c3fb commit 2ea948c

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

example/lib/main.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ class MyHomePageState extends State<MyHomePage> {
350350
Contact('Andrew', '[email protected]',
351351
'https://d2gg9evh47fn9z.cloudfront.net/800px_COLOURBOX4057996.jpg'),
352352
],
353+
max: 1,
353354
suggestionsCallback: (String query) {
354355
if (query.length != 0) {
355356
var lowercaseQuery = query.toLowerCase();
@@ -537,8 +538,9 @@ class MyHomePageState extends State<MyHomePage> {
537538
step: 1,
538539
),
539540
FormBuilderInput.signaturePad(
540-
decoration: InputDecoration(labelText: "Stepper"),
541+
decoration: InputDecoration(labelText: "Signature"),
541542
attribute: "signature",
543+
height: 100,
542544
require: true,
543545
),
544546
FormBuilderInput.rate(
@@ -602,3 +604,5 @@ class Contact {
602604
return name;
603605
}
604606
}
607+
608+

lib/src/form_builder.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ class FormBuilderState extends State<FormBuilder> {
207207

208208
case FormBuilderInput.TYPE_DATE_TIME_PICKER:
209209
return DateTimePickerFormField(
210+
key: _fieldKey,
210211
inputType: InputType.both,
211212
initialValue: formControl.value,
212213
format: formControl.format != null
@@ -232,6 +233,7 @@ class FormBuilderState extends State<FormBuilder> {
232233

233234
case FormBuilderInput.TYPE_DATE_PICKER:
234235
return DateTimePickerFormField(
236+
key: _fieldKey,
235237
inputType: InputType.date,
236238
initialValue: formControl.value,
237239
format: formControl.format != null
@@ -257,6 +259,7 @@ class FormBuilderState extends State<FormBuilder> {
257259

258260
case FormBuilderInput.TYPE_TIME_PICKER:
259261
return DateTimePickerFormField(
262+
key: _fieldKey,
260263
inputType: InputType.time,
261264
initialValue: formControl.value,
262265
format: formControl.format != null
@@ -812,6 +815,7 @@ class FormBuilderState extends State<FormBuilder> {
812815
onChanged: (data) {
813816
field.didChange(data);
814817
},
818+
maxChips: formControl.max,
815819
chipBuilder: formControl.chipBuilder,
816820
suggestionBuilder: formControl.suggestionBuilder,
817821
);

lib/src/form_builder_input.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,11 @@ class FormBuilderInput {
318318
this.value,
319319
this.require = false,
320320
this.validator,
321-
}) /*: assert(min == null || min is DateTime),
321+
}) /*: assert(min == null || min is DateTime),
322322
assert(max == null || max is DateTime),
323323
assert(min == null || firstDate == null),
324-
assert(max == null || lastDate == null)*/ {
324+
assert(max == null || lastDate == null)*/
325+
{
325326
type = FormBuilderInput.TYPE_DATE_PICKER;
326327
}
327328

@@ -339,10 +340,11 @@ class FormBuilderInput {
339340
this.value,
340341
this.require = false,
341342
this.validator,
342-
}) /*: assert(min == null || min is DateTime),
343+
}) /*: assert(min == null || min is DateTime),
343344
assert(max == null || max is DateTime),
344345
assert(min == null || firstDate == null),
345-
assert(max == null || lastDate == null) */{
346+
assert(max == null || lastDate == null) */
347+
{
346348
type = FormBuilderInput.TYPE_DATE_TIME_PICKER;
347349
}
348350

@@ -366,8 +368,10 @@ class FormBuilderInput {
366368
this.readonly = false,
367369
this.value,
368370
this.require = false,
371+
this.max,
369372
this.validator,
370-
}) : assert(value == null || value is List) {
373+
}) : assert(value == null || value is List),
374+
assert(max == null || max is int) {
371375
type = FormBuilderInput.TYPE_CHIPS_INPUT;
372376
}
373377
}

pubspec.lock

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,7 @@ packages:
4747
name: flutter_chips_input
4848
url: "https://pub.dartlang.org"
4949
source: hosted
50-
version: "1.1.0"
51-
flutter_signature_pad:
52-
dependency: "direct main"
53-
description:
54-
name: flutter_signature_pad
55-
url: "https://pub.dartlang.org"
56-
source: hosted
57-
version: "1.0.0"
50+
version: "1.2.0"
5851
flutter_test:
5952
dependency: "direct dev"
6053
description: flutter

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies:
1414
flutter_typeahead: ^1.2.1
1515
intl: ^0.15.7
1616
sy_flutter_widgets: ^0.1.4
17-
flutter_chips_input: ^1.1.0
17+
flutter_chips_input: ^1.2.0
1818
datetime_picker_formfield: ^0.1.8
1919
signature: ^2.0.0
2020

0 commit comments

Comments
 (0)