@@ -15,12 +15,15 @@ class MyApp extends StatelessWidget {
1515 'inputDisabled' : FormControl <Color >(disabled: true ),
1616 'inputList' : FormControl <List <Color >>(),
1717 'material' : FormControl <Color >(value: Colors .amber),
18- 'colorPicker' : FormControl <Color >(value: Colors .red),
18+ 'colorPicker' : FormControl <Color >(
19+ value: Colors .red, validators: [Validators .required ]),
1920 'sliderColorPicker' : FormControl <Color >(value: Colors .lime),
2021 });
2122
2223 @override
2324 Widget build (BuildContext context) {
25+ final textController = TextEditingController ();
26+
2427 return MaterialApp (
2528 theme: ThemeData (primarySwatch: Colors .blue),
2629 home: Scaffold (
@@ -37,32 +40,144 @@ class MyApp extends StatelessWidget {
3740 builder: (context, form, child) {
3841 return Column (
3942 children: [
40- const SizedBox (height: 16 ),
41- ReactiveBlockColorPicker <Color >(
42- formControlName: 'input' ,
43+ _Section (
44+ title: const Text ('colorPicker' ),
45+ child: ReactiveColorPicker <Color >(
46+ formControlName: 'colorPicker' ,
47+ ),
48+ ),
49+ _Section (
50+ title: const Text ('colorPicker with custom picker' ),
51+ child: ReactiveColorPicker <Color >(
52+ formControlName: 'colorPicker' ,
53+ pickerAreaHeightPercent: 0.7 ,
54+ displayThumbColor: true ,
55+ labelTypes: const [],
56+ hexInputController: textController,
57+ portraitOnly: true ,
58+ colorPickerBuilder: (pickColor, color) {
59+ return ListTile (
60+ title: const Text ('Color Picker' ),
61+ trailing: Container (
62+ width: 30 ,
63+ height: 30 ,
64+ decoration: BoxDecoration (
65+ color: color,
66+ borderRadius: BorderRadius .circular (8 ),
67+ border: Border .all (
68+ color: Colors .grey.shade400,
69+ ),
70+ ),
71+ ),
72+ onTap: pickColor,
73+ );
74+ },
75+ colorPickerDialogBuilder: (colorPicker) {
76+ final border = OutlineInputBorder (
77+ borderSide:
78+ const BorderSide (color: Color (0xFFD77243 )),
79+ borderRadius: BorderRadius .circular (12 ),
80+ );
81+ return AlertDialog (
82+ scrollable: true ,
83+ titlePadding: EdgeInsets .zero,
84+ contentPadding: EdgeInsets .zero,
85+ clipBehavior: Clip .antiAlias,
86+ shape: RoundedRectangleBorder (
87+ borderRadius: BorderRadius .circular (16 ),
88+ ),
89+ content: Column (
90+ children: [
91+ colorPicker,
92+ Padding (
93+ padding:
94+ const EdgeInsets .fromLTRB (16 , 0 , 16 , 16 ),
95+ child: Row (
96+ children: [
97+ Container (
98+ height: 40 ,
99+ padding: const EdgeInsets .symmetric (
100+ horizontal: 12 ,
101+ ),
102+ decoration: BoxDecoration (
103+ border: Border .all (
104+ color: const Color (0xFFD77243 ),
105+ ),
106+ borderRadius:
107+ BorderRadius .circular (12 ),
108+ ),
109+ child: const Center (
110+ child: Text (
111+ 'HEX' ,
112+ style: TextStyle (
113+ color: Color (0xFF0F1111 ),
114+ fontSize: 12 ,
115+ fontWeight: FontWeight .w400,
116+ ),
117+ ),
118+ ),
119+ ),
120+ const SizedBox (width: 8 ),
121+ Expanded (
122+ child: SizedBox (
123+ height: 40 ,
124+ child: TextField (
125+ decoration: InputDecoration (
126+ enabledBorder: border,
127+ focusedBorder: border,
128+ border: border,
129+ counterText: '' ,
130+ ),
131+ controller: textController,
132+ style: const TextStyle (
133+ color: Color (0xFF0F1111 ),
134+ fontSize: 12 ,
135+ fontWeight: FontWeight .w400,
136+ ),
137+ autofocus: true ,
138+ maxLength: 9 ,
139+ ),
140+ ),
141+ ),
142+ ],
143+ ),
144+ ),
145+ ],
146+ ),
147+ );
148+ },
149+ ),
43150 ),
44- const SizedBox (height: 16 ),
45- ReactiveBlockColorPicker <Color >(
46- formControlName: 'inputDisabled' ,
151+ _Section (
152+ title: const Text ('BlockColorPicker' ),
153+ child: ReactiveBlockColorPicker <Color >(
154+ formControlName: 'input' ,
155+ ),
47156 ),
48- const SizedBox (height: 16 ),
49- ReactiveMultipleBlockColorPicker <List <Color >>(
50- formControlName: 'inputList' ,
157+ _Section (
158+ title: const Text ('BlockColorPicker disabled' ),
159+ child: ReactiveBlockColorPicker <Color >(
160+ formControlName: 'inputDisabled' ,
161+ ),
51162 ),
52- const SizedBox (height: 16 ),
53- ReactiveMaterialColorPicker <Color >(
54- formControlName: 'material' ,
163+ _Section (
164+ title: const Text ('MultipleBlockColorPicker' ),
165+ child: ReactiveMultipleBlockColorPicker <List <Color >>(
166+ formControlName: 'inputList' ,
167+ ),
55168 ),
56- const SizedBox (height: 16 ),
57- ReactiveColorPicker <Color >(
58- formControlName: 'colorPicker' ,
59- enableAlpha: false ,
169+ _Section (
170+ title: const Text ('MaterialColorPicker' ),
171+ child: ReactiveMaterialColorPicker <Color >(
172+ formControlName: 'material' ,
173+ ),
60174 ),
61- const SizedBox (height: 16 ),
62- ReactiveSliderColorPicker <Color >(
63- formControlName: 'sliderColorPicker' ,
175+ _Section (
176+ title: const Text ('SliderColorPicker' ),
177+ child: ReactiveSliderColorPicker <Color >(
178+ formControlName: 'sliderColorPicker' ,
179+ ),
64180 ),
65- const SizedBox (height: 16 ),
66181 ElevatedButton (
67182 child: const Text ('Sign Up' ),
68183 onPressed: () {
@@ -84,3 +199,28 @@ class MyApp extends StatelessWidget {
84199 );
85200 }
86201}
202+
203+ class _Section extends StatelessWidget {
204+ final Widget title;
205+ final Widget child;
206+
207+ const _Section ({
208+ required this .title,
209+ required this .child,
210+ });
211+
212+ @override
213+ Widget build (BuildContext context) {
214+ return Padding (
215+ padding: const EdgeInsets .only (bottom: 16 ),
216+ child: Column (
217+ crossAxisAlignment: CrossAxisAlignment .start,
218+ children: [
219+ title,
220+ const SizedBox (height: 8 ),
221+ child,
222+ ],
223+ ),
224+ );
225+ }
226+ }
0 commit comments