@@ -35,72 +35,74 @@ class _MyHomePageState extends State<MyHomePage> {
3535 @override
3636 Widget build (BuildContext context) {
3737 return CupertinoPageScaffold (
38- child: Padding (
39- padding: const EdgeInsets .all (24 ),
40- child: FormBuilder (
41- key: _formKey,
42- child: Column (
43- children: [
44- FormBuilderCupertinoCheckbox (
45- name: 'checkbox' ,
46- prefix: const Text ('Select/Unselect' ),
47- ),
48- const SizedBox (height: 16 ),
49- FormBuilderCupertinoSegmentedControl <int >(
50- name: 'segmented_control' ,
51- shouldExpandedField: true ,
52- autovalidateMode: AutovalidateMode .always,
53- options: const [
54- FormBuilderFieldOption (value: 1 , child: Text ('First' )),
55- FormBuilderFieldOption (value: 2 , child: Text ('Second' )),
56- FormBuilderFieldOption (value: 3 , child: Text ('Third' )),
57- ],
58- prefix: const Icon (CupertinoIcons .add),
59- validator: (value) => value != null ? null : 'Required field' ,
60- // initialValue: 1,
61- ),
62- const SizedBox (height: 16 ),
63- FormBuilderCupertinoSlidingSegmentedControl <String >(
64- name: 'segmented_sliding_control' ,
65- options: const [
66- FormBuilderFieldOption (value: '1' , child: Text ('1' )),
67- FormBuilderFieldOption (value: '2' , child: Text ('2' )),
68- FormBuilderFieldOption (value: '3' , child: Text ('3' )),
69- ],
70- helper: const Text ('Select the numbers' ),
71- prefix: const Icon (CupertinoIcons .number),
72- ),
73- const SizedBox (height: 16 ),
74- FormBuilderCupertinoSwitch (
75- name: 'switch' ,
76- initialValue: true ,
77- prefix: const Text ('Enable/Disabled' ),
78- ),
79- const SizedBox (height: 16 ),
80- FormBuilderCupertinoSlider (
81- name: 'slider' ,
82- initialValue: 10 ,
83- autovalidateMode: AutovalidateMode .onUserInteraction,
84- min: 1 ,
85- max: 100 ,
86- validator: (value) => value != null && value < 50 && value > 5
87- ? null
88- : 'Required value between 5 and 50' ,
89- ),
90- const SizedBox (height: 16 ),
91- FormBuilderCupertinoTextField (
92- name: 'text' ,
93- decoration: BoxDecoration (
94- border: Border .all (
95- color: CupertinoColors .black,
96- ),
97- borderRadius: BorderRadius .circular (8 ),
38+ child: SafeArea (
39+ child: Padding (
40+ padding: const EdgeInsets .all (24 ),
41+ child: FormBuilder (
42+ key: _formKey,
43+ child: Column (
44+ children: [
45+ FormBuilderCupertinoCheckbox (
46+ name: 'checkbox' ,
47+ prefix: const Text ('Select/Unselect' ),
48+ ),
49+ const SizedBox (height: 16 ),
50+ FormBuilderCupertinoSegmentedControl <int >(
51+ name: 'segmented_control' ,
52+ shouldExpandedField: true ,
53+ autovalidateMode: AutovalidateMode .always,
54+ options: const [
55+ FormBuilderFieldOption (value: 1 , child: Text ('First' )),
56+ FormBuilderFieldOption (value: 2 , child: Text ('Second' )),
57+ FormBuilderFieldOption (value: 3 , child: Text ('Third' )),
58+ ],
59+ prefix: const Icon (CupertinoIcons .add),
60+ validator: (value) => value != null ? null : 'Required field' ,
61+ // initialValue: 1,
62+ ),
63+ const SizedBox (height: 16 ),
64+ FormBuilderCupertinoSlidingSegmentedControl <String >(
65+ name: 'segmented_sliding_control' ,
66+ options: const [
67+ FormBuilderFieldOption (value: '1' , child: Text ('1' )),
68+ FormBuilderFieldOption (value: '2' , child: Text ('2' )),
69+ FormBuilderFieldOption (value: '3' , child: Text ('3' )),
70+ ],
71+ helper: const Text ('Select the numbers' ),
72+ prefix: const Icon (CupertinoIcons .number),
9873 ),
99- autovalidateMode: AutovalidateMode .onUserInteraction,
100- validator: (value) =>
101- value != null && value.length > 4 ? null : 'Write a text' ,
102- )
103- ],
74+ const SizedBox (height: 16 ),
75+ FormBuilderCupertinoSwitch (
76+ name: 'switch' ,
77+ initialValue: true ,
78+ prefix: const Text ('Enable/Disabled' ),
79+ ),
80+ const SizedBox (height: 16 ),
81+ FormBuilderCupertinoSlider (
82+ name: 'slider' ,
83+ initialValue: 10 ,
84+ autovalidateMode: AutovalidateMode .onUserInteraction,
85+ min: 1 ,
86+ max: 100 ,
87+ validator: (value) => value != null && value < 50 && value > 5
88+ ? null
89+ : 'Required value between 5 and 50' ,
90+ ),
91+ const SizedBox (height: 16 ),
92+ FormBuilderCupertinoTextField (
93+ name: 'text' ,
94+ decoration: BoxDecoration (
95+ border: Border .all (
96+ color: CupertinoColors .black,
97+ ),
98+ borderRadius: BorderRadius .circular (8 ),
99+ ),
100+ autovalidateMode: AutovalidateMode .onUserInteraction,
101+ validator: (value) =>
102+ value != null && value.length > 4 ? null : 'Write a text' ,
103+ )
104+ ],
105+ ),
104106 ),
105107 ),
106108 ), // This trailing comma makes auto-formatting nicer for build methods.
0 commit comments