@@ -189,23 +189,25 @@ class _ExpansionPanelsDemoState extends State<ExpasionPanelsDemo> {
189
189
});
190
190
}
191
191
192
- return new CollapsibleBody (
193
- margin: const EdgeInsets .symmetric (horizontal: 16.0 ),
194
- child: new Form (
195
- child: new Padding (
196
- padding: const EdgeInsets .symmetric (horizontal: 16.0 ),
197
- child: new Input (
198
- hintText: item.hint,
199
- labelText: item.name,
200
- value: new InputValue (text: item.value),
201
- formField: new FormField <String >(
202
- setter: (String val) { item.value = val; }
192
+ return new Form (
193
+ child: new Builder (
194
+ builder: (BuildContext context) {
195
+ return new CollapsibleBody (
196
+ margin: const EdgeInsets .symmetric (horizontal: 16.0 ),
197
+ onSave: () { Form .of (context).save (); close (); },
198
+ onCancel: () { Form .of (context).reset (); close (); },
199
+ child: new Padding (
200
+ padding: const EdgeInsets .symmetric (horizontal: 16.0 ),
201
+ child: new InputFormField (
202
+ hintText: item.hint,
203
+ labelText: item.name,
204
+ initialValue: new InputValue (text: item.value),
205
+ onSaved: (InputValue val) { item.value = val.text; },
206
+ ),
203
207
),
204
- ),
205
- ),
206
- ),
207
- onSave: close,
208
- onCancel: close
208
+ );
209
+ }
210
+ )
209
211
);
210
212
}
211
213
),
@@ -221,54 +223,61 @@ class _ExpansionPanelsDemoState extends State<ExpasionPanelsDemo> {
221
223
});
222
224
}
223
225
224
- void changeLocation (_Location newLocation) {
225
- setState (() {
226
- item.value = newLocation;
227
- });
228
- }
229
226
230
- return new CollapsibleBody (
231
- child: new Column (
232
- mainAxisSize: MainAxisSize .min,
233
- crossAxisAlignment: CrossAxisAlignment .start,
234
- children: < Widget > [
235
- new Row (
236
- mainAxisSize: MainAxisSize .min,
237
- children: < Widget > [
238
- new Radio <_Location >(
239
- value: _Location .Bahamas ,
240
- groupValue: item.value,
241
- onChanged: changeLocation
242
- ),
243
- new Text ('Bahamas' )
244
- ]
245
- ),
246
- new Row (
247
- mainAxisSize: MainAxisSize .min,
248
- children: < Widget > [
249
- new Radio <_Location >(
250
- value: _Location .Barbados ,
251
- groupValue: item.value,
252
- onChanged: changeLocation
253
- ),
254
- new Text ('Barbados' )
255
- ]
256
- ),
257
- new Row (
258
- mainAxisSize: MainAxisSize .min,
259
- children: < Widget > [
260
- new Radio <_Location >(
261
- value: _Location .Bermuda ,
262
- groupValue: item.value,
263
- onChanged: changeLocation
264
- ),
265
- new Text ('Bermuda' )
266
- ]
267
- )
268
- ]
269
- ),
270
- onSave: close,
271
- onCancel: close
227
+ return new Form (
228
+ child: new Builder (
229
+ builder: (BuildContext context) {
230
+ return new CollapsibleBody (
231
+ onSave: () { Form .of (context).save (); close (); },
232
+ onCancel: () { Form .of (context).reset (); close (); },
233
+ child: new FormField <_Location >(
234
+ initialValue: item.value,
235
+ onSaved: (_Location result) { item.value = result; },
236
+ builder: (FormFieldState <_Location > field) {
237
+ return new Column (
238
+ mainAxisSize: MainAxisSize .min,
239
+ crossAxisAlignment: CrossAxisAlignment .start,
240
+ children: < Widget > [
241
+ new Row (
242
+ mainAxisSize: MainAxisSize .min,
243
+ children: < Widget > [
244
+ new Radio <_Location >(
245
+ value: _Location .Bahamas ,
246
+ groupValue: field.value,
247
+ onChanged: field.onChanged,
248
+ ),
249
+ new Text ('Bahamas' )
250
+ ]
251
+ ),
252
+ new Row (
253
+ mainAxisSize: MainAxisSize .min,
254
+ children: < Widget > [
255
+ new Radio <_Location >(
256
+ value: _Location .Barbados ,
257
+ groupValue: field.value,
258
+ onChanged: field.onChanged,
259
+ ),
260
+ new Text ('Barbados' )
261
+ ]
262
+ ),
263
+ new Row (
264
+ mainAxisSize: MainAxisSize .min,
265
+ children: < Widget > [
266
+ new Radio <_Location >(
267
+ value: _Location .Bermuda ,
268
+ groupValue: field.value,
269
+ onChanged: field.onChanged,
270
+ ),
271
+ new Text ('Bermuda' )
272
+ ]
273
+ )
274
+ ]
275
+ );
276
+ }
277
+ ),
278
+ );
279
+ }
280
+ )
272
281
);
273
282
}
274
283
),
@@ -284,22 +293,30 @@ class _ExpansionPanelsDemoState extends State<ExpasionPanelsDemo> {
284
293
});
285
294
}
286
295
287
- return new CollapsibleBody (
288
- child: new Slider (
289
- value: item.value,
290
- min: 0.0 ,
291
- max: 100.0 ,
292
- divisions: 5 ,
293
- activeColor: Colors .orange[100 + (item.value * 5.0 ).round ()],
294
- label: '${item .value .round ()}' ,
295
- onChanged: (double value) {
296
- setState (() {
297
- item.value = value;
298
- });
296
+ return new Form (
297
+ child: new Builder (
298
+ builder: (BuildContext context) {
299
+ return new CollapsibleBody (
300
+ onSave: () { Form .of (context).save (); close (); },
301
+ onCancel: () { Form .of (context).reset (); close (); },
302
+ child: new FormField <double >(
303
+ initialValue: item.value,
304
+ onSaved: (double value) { item.value = value; },
305
+ builder: (FormFieldState <double > field) {
306
+ return new Slider (
307
+ min: 0.0 ,
308
+ max: 100.0 ,
309
+ divisions: 5 ,
310
+ activeColor: Colors .orange[100 + (field.value * 5.0 ).round ()],
311
+ label: '${field .value .round ()}' ,
312
+ value: field.value,
313
+ onChanged: field.onChanged,
314
+ );
315
+ },
316
+ ),
317
+ );
299
318
}
300
- ),
301
- onSave: close,
302
- onCancel: close
319
+ )
303
320
);
304
321
}
305
322
)
0 commit comments