Skip to content

Commit 2e3b803

Browse files
committed
Added keys to all Formfields, other minor fixes
1 parent ed0666f commit 2e3b803

File tree

6 files changed

+467
-161
lines changed

6 files changed

+467
-161
lines changed

.idea/workspace.xml

Lines changed: 133 additions & 119 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,10 @@
4949
* Fixed bug where validation not working for fields outside screen (when using ListView) - [Flutter Issue #17385](https://github.com/flutter/flutter/issues/17385)
5050
* Added InputDecoration for all custom FormFields
5151

52+
## [1.2.0] - 23-Nov-2018
53+
* New `FormBuilderInput` types:
54+
* ChipsInput
55+
* Some bug fixes
56+
* Minor UI improvements
57+
* Some bugs introduced, to be fixed later
58+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,5 +193,5 @@ FormBuilder(
193193
* Resetting the form doesn't clear all `FormField`s
194194
* Overlay for ChipsInput doesn't move when input height changes i.e. when chips wrap
195195
* For some reason Overlay for ChipsInput floats above AppBar when scrolling
196-
* DatePicker and TimePicker Textfields don't get focus when selecting
196+
* TypeAhead text gets cleared when Dropdown/ChipsInput value changes. What the Flip????
197197

example/lib/main.dart

Lines changed: 283 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,247 @@ class MyHomePage extends StatelessWidget {
4646
'https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png'),
4747
];
4848

49-
const allCountries = ["Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegowina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia (Hrvatska)", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "France Metropolitan", "French Guiana", "French Polynesia", "French Southern Territories", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard and Mc Donald Islands", "Holy See (Vatican City State)", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran (Islamic Republic of)", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, Democratic People's Republic of", "Korea, Republic of", "Kuwait", "Kyrgyzstan", "Lao, People's Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libyan Arab Jamahiriya", "Liechtenstein", "Lithuania", "Luxembourg", "Macau", "Macedonia, The Former Yugoslav Republic of", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia, Federated States of", "Moldova, Republic of", "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion", "Romania", "Russian Federation", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Seychelles", "Sierra Leone", "Singapore", "Slovakia (Slovak Republic)", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "Spain", "Sri Lanka", "St. Helena", "St. Pierre and Miquelon", "Sudan", "Suriname", "Svalbard and Jan Mayen Islands", "Swaziland", "Sweden", "Switzerland", "Syrian Arab Republic", "Taiwan, Province of China", "Tajikistan", "Tanzania, United Republic of", "Thailand", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin Islands (British)", "Virgin Islands (U.S.)", "Wallis and Futuna Islands", "Western Sahara", "Yemen", "Yugoslavia", "Zambia", "Zimbabwe"];
50-
49+
const allCountries = [
50+
"Afghanistan",
51+
"Albania",
52+
"Algeria",
53+
"American Samoa",
54+
"Andorra",
55+
"Angola",
56+
"Anguilla",
57+
"Antarctica",
58+
"Antigua and Barbuda",
59+
"Argentina",
60+
"Armenia",
61+
"Aruba",
62+
"Australia",
63+
"Austria",
64+
"Azerbaijan",
65+
"Bahamas",
66+
"Bahrain",
67+
"Bangladesh",
68+
"Barbados",
69+
"Belarus",
70+
"Belgium",
71+
"Belize",
72+
"Benin",
73+
"Bermuda",
74+
"Bhutan",
75+
"Bolivia",
76+
"Bosnia and Herzegowina",
77+
"Botswana",
78+
"Bouvet Island",
79+
"Brazil",
80+
"British Indian Ocean Territory",
81+
"Brunei Darussalam",
82+
"Bulgaria",
83+
"Burkina Faso",
84+
"Burundi",
85+
"Cambodia",
86+
"Cameroon",
87+
"Canada",
88+
"Cape Verde",
89+
"Cayman Islands",
90+
"Central African Republic",
91+
"Chad",
92+
"Chile",
93+
"China",
94+
"Christmas Island",
95+
"Cocos (Keeling) Islands",
96+
"Colombia",
97+
"Comoros",
98+
"Congo",
99+
"Congo, the Democratic Republic of the",
100+
"Cook Islands",
101+
"Costa Rica",
102+
"Cote d'Ivoire",
103+
"Croatia (Hrvatska)",
104+
"Cuba",
105+
"Cyprus",
106+
"Czech Republic",
107+
"Denmark",
108+
"Djibouti",
109+
"Dominica",
110+
"Dominican Republic",
111+
"East Timor",
112+
"Ecuador",
113+
"Egypt",
114+
"El Salvador",
115+
"Equatorial Guinea",
116+
"Eritrea",
117+
"Estonia",
118+
"Ethiopia",
119+
"Falkland Islands (Malvinas)",
120+
"Faroe Islands",
121+
"Fiji",
122+
"Finland",
123+
"France",
124+
"France Metropolitan",
125+
"French Guiana",
126+
"French Polynesia",
127+
"French Southern Territories",
128+
"Gabon",
129+
"Gambia",
130+
"Georgia",
131+
"Germany",
132+
"Ghana",
133+
"Gibraltar",
134+
"Greece",
135+
"Greenland",
136+
"Grenada",
137+
"Guadeloupe",
138+
"Guam",
139+
"Guatemala",
140+
"Guinea",
141+
"Guinea-Bissau",
142+
"Guyana",
143+
"Haiti",
144+
"Heard and Mc Donald Islands",
145+
"Holy See (Vatican City State)",
146+
"Honduras",
147+
"Hong Kong",
148+
"Hungary",
149+
"Iceland",
150+
"India",
151+
"Indonesia",
152+
"Iran (Islamic Republic of)",
153+
"Iraq",
154+
"Ireland",
155+
"Israel",
156+
"Italy",
157+
"Jamaica",
158+
"Japan",
159+
"Jordan",
160+
"Kazakhstan",
161+
"Kenya",
162+
"Kiribati",
163+
"Korea, Democratic People's Republic of",
164+
"Korea, Republic of",
165+
"Kuwait",
166+
"Kyrgyzstan",
167+
"Lao, People's Democratic Republic",
168+
"Latvia",
169+
"Lebanon",
170+
"Lesotho",
171+
"Liberia",
172+
"Libyan Arab Jamahiriya",
173+
"Liechtenstein",
174+
"Lithuania",
175+
"Luxembourg",
176+
"Macau",
177+
"Macedonia, The Former Yugoslav Republic of",
178+
"Madagascar",
179+
"Malawi",
180+
"Malaysia",
181+
"Maldives",
182+
"Mali",
183+
"Malta",
184+
"Marshall Islands",
185+
"Martinique",
186+
"Mauritania",
187+
"Mauritius",
188+
"Mayotte",
189+
"Mexico",
190+
"Micronesia, Federated States of",
191+
"Moldova, Republic of",
192+
"Monaco",
193+
"Mongolia",
194+
"Montserrat",
195+
"Morocco",
196+
"Mozambique",
197+
"Myanmar",
198+
"Namibia",
199+
"Nauru",
200+
"Nepal",
201+
"Netherlands",
202+
"Netherlands Antilles",
203+
"New Caledonia",
204+
"New Zealand",
205+
"Nicaragua",
206+
"Niger",
207+
"Nigeria",
208+
"Niue",
209+
"Norfolk Island",
210+
"Northern Mariana Islands",
211+
"Norway",
212+
"Oman",
213+
"Pakistan",
214+
"Palau",
215+
"Panama",
216+
"Papua New Guinea",
217+
"Paraguay",
218+
"Peru",
219+
"Philippines",
220+
"Pitcairn",
221+
"Poland",
222+
"Portugal",
223+
"Puerto Rico",
224+
"Qatar",
225+
"Reunion",
226+
"Romania",
227+
"Russian Federation",
228+
"Rwanda",
229+
"Saint Kitts and Nevis",
230+
"Saint Lucia",
231+
"Saint Vincent and the Grenadines",
232+
"Samoa",
233+
"San Marino",
234+
"Sao Tome and Principe",
235+
"Saudi Arabia",
236+
"Senegal",
237+
"Seychelles",
238+
"Sierra Leone",
239+
"Singapore",
240+
"Slovakia (Slovak Republic)",
241+
"Slovenia",
242+
"Solomon Islands",
243+
"Somalia",
244+
"South Africa",
245+
"South Georgia and the South Sandwich Islands",
246+
"Spain",
247+
"Sri Lanka",
248+
"St. Helena",
249+
"St. Pierre and Miquelon",
250+
"Sudan",
251+
"Suriname",
252+
"Svalbard and Jan Mayen Islands",
253+
"Swaziland",
254+
"Sweden",
255+
"Switzerland",
256+
"Syrian Arab Republic",
257+
"Taiwan, Province of China",
258+
"Tajikistan",
259+
"Tanzania, United Republic of",
260+
"Thailand",
261+
"Togo",
262+
"Tokelau",
263+
"Tonga",
264+
"Trinidad and Tobago",
265+
"Tunisia",
266+
"Turkey",
267+
"Turkmenistan",
268+
"Turks and Caicos Islands",
269+
"Tuvalu",
270+
"Uganda",
271+
"Ukraine",
272+
"United Arab Emirates",
273+
"United Kingdom",
274+
"United States",
275+
"United States Minor Outlying Islands",
276+
"Uruguay",
277+
"Uzbekistan",
278+
"Vanuatu",
279+
"Venezuela",
280+
"Vietnam",
281+
"Virgin Islands (British)",
282+
"Virgin Islands (U.S.)",
283+
"Wallis and Futuna Islands",
284+
"Western Sahara",
285+
"Yemen",
286+
"Yugoslavia",
287+
"Zambia",
288+
"Zimbabwe"
289+
];
51290

52291
return Scaffold(
53292
appBar: AppBar(
@@ -61,17 +300,55 @@ class MyHomePage extends StatelessWidget {
61300
showResetButton: true,
62301
// resetButtonContent: Text("Clear Form"),
63302
controls: [
303+
FormBuilderInput.typeAhead(
304+
label: 'Country',
305+
attribute: 'country',
306+
require: true,
307+
value: 'Kenya',
308+
itemBuilder: (context, country) {
309+
return ListTile(
310+
title: Text(country),
311+
);
312+
},
313+
suggestionsCallback: (query) {
314+
if (query.length != 0) {
315+
var lowercaseQuery = query.toLowerCase();
316+
return allCountries.where((country) {
317+
return country.toLowerCase().contains(lowercaseQuery);
318+
}).toList(growable: false)
319+
..sort((a, b) => a
320+
.toLowerCase()
321+
.indexOf(lowercaseQuery)
322+
.compareTo(b.toLowerCase().indexOf(lowercaseQuery)));
323+
} else {
324+
return allCountries;
325+
}
326+
},
327+
),
64328
FormBuilderInput.chipsInput(
65329
label: 'Chips',
66330
attribute: 'chips_test',
67331
require: true,
68-
value: [AppProfile('Andrew', '[email protected]','https://d2gg9evh47fn9z.cloudfront.net/800px_COLOURBOX4057996.jpg')],
332+
value: [
333+
AppProfile('Andrew', '[email protected]',
334+
'https://d2gg9evh47fn9z.cloudfront.net/800px_COLOURBOX4057996.jpg')
335+
],
69336
suggestionsCallback: (String query) {
70337
if (query.length != 0) {
338+
var lowercaseQuery = query.toLowerCase();
71339
return mockResults.where((profile) {
72-
return profile.name.toLowerCase().contains(query.toLowerCase()) ||
73-
profile.email.toLowerCase().contains(query.toLowerCase());
74-
}).toList(growable: false);
340+
return profile.name
341+
.toLowerCase()
342+
.contains(query.toLowerCase()) ||
343+
profile.email
344+
.toLowerCase()
345+
.contains(query.toLowerCase());
346+
}).toList(growable: false)
347+
..sort((a, b) => a.name
348+
.toLowerCase()
349+
.indexOf(lowercaseQuery)
350+
.compareTo(b.name.toLowerCase().indexOf(lowercaseQuery)));
351+
;
75352
} else {
76353
return const <AppProfile>[];
77354
}
@@ -99,25 +376,6 @@ class MyHomePage extends StatelessWidget {
99376
);
100377
},
101378
),
102-
FormBuilderInput.typeAhead(
103-
label: 'Country',
104-
attribute: 'country',
105-
require: true,
106-
itemBuilder: (context, country) {
107-
return ListTile(
108-
title: Text(country),
109-
);
110-
},
111-
suggestionsCallback: (query) {
112-
if (query.length != 0) {
113-
return allCountries.where((country) {
114-
return country.toLowerCase().contains(query.toLowerCase());
115-
}).toList(growable: false);
116-
} else {
117-
return allCountries;
118-
}
119-
},
120-
),
121379
FormBuilderInput.textField(
122380
type: FormBuilderInput.TYPE_TEXT,
123381
attribute: "name",

lib/src/chips_input.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class ChipsInputState<T> extends State<ChipsInput<T>>
4242
TextEditingValue _value = TextEditingValue();
4343
TextInputConnection _connection;
4444
_SuggestionsBoxController _suggestionsBoxController;
45-
final LayerLink _layerLink = LayerLink();
45+
LayerLink _layerLink = LayerLink();
46+
Size size;
4647

4748
String get text => String.fromCharCodes(
4849
_value.text.codeUnits.where((ch) => ch != kObjectReplacementChar),
@@ -99,7 +100,8 @@ class ChipsInputState<T> extends State<ChipsInput<T>>
99100
await Future.delayed(Duration(milliseconds: 10));
100101
}
101102

102-
var size = renderBox.size;
103+
size = renderBox.size;
104+
print(size);
103105

104106
this._suggestionsBoxController._overlayEntry = OverlayEntry(
105107
builder: (context) {
@@ -263,7 +265,7 @@ class ChipsInputState<T> extends State<ChipsInput<T>>
263265
selection: TextSelection.collapsed(offset: text.length),
264266
composing: TextRange(start: 0, end: text.length),
265267
);
266-
if(_connection == null)
268+
if (_connection == null)
267269
_connection = TextInput.attach(this, TextInputConfiguration());
268270
_connection.setEditingState(_value);
269271
}

0 commit comments

Comments
 (0)