@@ -152,13 +152,16 @@ class CountryCodePicker extends StatefulWidget {
152152 this .closeIcon = const Icon (Icons .close),
153153 this .countryList = codes,
154154 this .pickerStyle = PickerStyle .dialog,
155- this .dialogItemPadding = const EdgeInsets .symmetric (horizontal: 24 , vertical: 8 ),
155+ this .dialogItemPadding =
156+ const EdgeInsets .symmetric (horizontal: 24 , vertical: 8 ),
156157 this .searchPadding = const EdgeInsets .symmetric (horizontal: 24 ),
157158 this .headerAlignment = MainAxisAlignment .spaceBetween,
158159 this .headerText = "Select County" ,
159- this .headerTextStyle = const TextStyle (fontSize: 18 , fontWeight: FontWeight .bold),
160+ this .headerTextStyle =
161+ const TextStyle (fontSize: 18 , fontWeight: FontWeight .bold),
160162 this .hideHeaderText = false ,
161- this .topBarPadding = const EdgeInsets .symmetric (vertical: 5.0 , horizontal: 20 ),
163+ this .topBarPadding =
164+ const EdgeInsets .symmetric (vertical: 5.0 , horizontal: 20 ),
162165 Key ? key,
163166 }) : super (key: key);
164167
@@ -167,15 +170,22 @@ class CountryCodePicker extends StatefulWidget {
167170 State <StatefulWidget > createState () {
168171 List <Map <String , String >> jsonList = countryList;
169172
170- List <CountryCode > elements = jsonList.map ((json) => CountryCode .fromJson (json)).toList ();
173+ List <CountryCode > elements =
174+ jsonList.map ((json) => CountryCode .fromJson (json)).toList ();
171175
172176 if (comparator != null ) {
173177 elements.sort (comparator);
174178 }
175179
176180 if (countryFilter != null && countryFilter! .isNotEmpty) {
177- final uppercaseCustomList = countryFilter! .map ((criteria) => criteria.toUpperCase ()).toList ();
178- elements = elements.where ((criteria) => uppercaseCustomList.contains (criteria.code) || uppercaseCustomList.contains (criteria.name) || uppercaseCustomList.contains (criteria.dialCode)).toList ();
181+ final uppercaseCustomList =
182+ countryFilter! .map ((criteria) => criteria.toUpperCase ()).toList ();
183+ elements = elements
184+ .where ((criteria) =>
185+ uppercaseCustomList.contains (criteria.code) ||
186+ uppercaseCustomList.contains (criteria.name) ||
187+ uppercaseCustomList.contains (criteria.dialCode))
188+ .toList ();
179189 }
180190
181191 return CountryCodePickerState (elements, pickerStyle);
@@ -197,7 +207,7 @@ class CountryCodePickerState extends State<CountryCodePicker> {
197207 internalWidget = InkWell (
198208 onTap: pickerStyle == PickerStyle .dialog
199209 ? showCountryCodePickerDialog
200- : showCountryCodePickerBottomSheet
210+ : showCountryCodePickerBottomSheet,
201211 child: widget.builder !(selectedItem),
202212 );
203213 } else {
@@ -213,14 +223,21 @@ class CountryCodePickerState extends State<CountryCodePicker> {
213223 direction: Axis .horizontal,
214224 mainAxisSize: MainAxisSize .min,
215225 children: < Widget > [
216- if (widget.showFlagMain != null ? widget.showFlagMain! : widget.showFlag)
226+ if (widget.showFlagMain != null
227+ ? widget.showFlagMain!
228+ : widget.showFlag)
217229 Flexible (
218230 flex: widget.alignLeft ? 0 : 1 ,
219231 fit: widget.alignLeft ? FlexFit .tight : FlexFit .loose,
220232 child: Container (
221- clipBehavior: widget.flagDecoration == null ? Clip .none : Clip .hardEdge,
233+ clipBehavior: widget.flagDecoration == null
234+ ? Clip .none
235+ : Clip .hardEdge,
222236 decoration: widget.flagDecoration,
223- margin: widget.margin ?? (widget.alignLeft ? const EdgeInsets .only (right: 16.0 , left: 8.0 ) : const EdgeInsets .only (right: 16.0 )),
237+ margin: widget.margin ??
238+ (widget.alignLeft
239+ ? const EdgeInsets .only (right: 16.0 , left: 8.0 )
240+ : const EdgeInsets .only (right: 16.0 )),
224241 child: Image .asset (
225242 selectedItem! .flagUri! ,
226243 package: 'country_code_picker' ,
@@ -232,8 +249,11 @@ class CountryCodePickerState extends State<CountryCodePicker> {
232249 Flexible (
233250 fit: widget.alignLeft ? FlexFit .tight : FlexFit .loose,
234251 child: Text (
235- widget.showOnlyCountryWhenClosed ? selectedItem! .toCountryStringOnly () : selectedItem.toString (),
236- style: widget.textStyle ?? Theme .of (context).textTheme.labelLarge,
252+ widget.showOnlyCountryWhenClosed
253+ ? selectedItem! .toCountryStringOnly ()
254+ : selectedItem.toString (),
255+ style: widget.textStyle ??
256+ Theme .of (context).textTheme.labelLarge,
237257 overflow: widget.textOverflow,
238258 ),
239259 ),
@@ -242,7 +262,9 @@ class CountryCodePickerState extends State<CountryCodePicker> {
242262 flex: widget.alignLeft ? 0 : 1 ,
243263 fit: widget.alignLeft ? FlexFit .tight : FlexFit .loose,
244264 child: Padding (
245- padding: (widget.alignLeft ? const EdgeInsets .only (right: 16.0 , left: 8.0 ) : const EdgeInsets .only (right: 16.0 )),
265+ padding: (widget.alignLeft
266+ ? const EdgeInsets .only (right: 16.0 , left: 8.0 )
267+ : const EdgeInsets .only (right: 16.0 )),
246268 child: Icon (
247269 Icons .arrow_drop_down,
248270 color: Colors .grey,
@@ -273,9 +295,11 @@ class CountryCodePickerState extends State<CountryCodePicker> {
273295 if (widget.initialSelection != null ) {
274296 selectedItem = elements.firstWhere (
275297 (criteria) =>
276- (criteria.code! .toUpperCase () == widget.initialSelection! .toUpperCase ()) ||
298+ (criteria.code! .toUpperCase () ==
299+ widget.initialSelection! .toUpperCase ()) ||
277300 (criteria.dialCode == widget.initialSelection) ||
278- (criteria.name! .toUpperCase () == widget.initialSelection! .toUpperCase ()),
301+ (criteria.name! .toUpperCase () ==
302+ widget.initialSelection! .toUpperCase ()),
279303 orElse: () => elements[0 ]);
280304 } else {
281305 selectedItem = elements[0 ];
@@ -291,24 +315,29 @@ class CountryCodePickerState extends State<CountryCodePicker> {
291315 if (widget.initialSelection != null ) {
292316 selectedItem = elements.firstWhere (
293317 (item) =>
294- (item.code! .toUpperCase () == widget.initialSelection! .toUpperCase ()) ||
318+ (item.code! .toUpperCase () ==
319+ widget.initialSelection! .toUpperCase ()) ||
295320 (item.dialCode == widget.initialSelection) ||
296- (item.name! .toUpperCase () == widget.initialSelection! .toUpperCase ()),
321+ (item.name! .toUpperCase () ==
322+ widget.initialSelection! .toUpperCase ()),
297323 orElse: () => elements[0 ]);
298324 } else {
299325 selectedItem = elements[0 ];
300326 }
301327
302328 favoriteElements = elements
303329 .where ((item) =>
304- widget.favorite.firstWhereOrNull ((criteria) => item.code! .toUpperCase () == criteria.toUpperCase () || item.dialCode == criteria || item.name! .toUpperCase () == criteria.toUpperCase ()) !=
330+ widget.favorite.firstWhereOrNull ((criteria) =>
331+ item.code! .toUpperCase () == criteria.toUpperCase () ||
332+ item.dialCode == criteria ||
333+ item.name! .toUpperCase () == criteria.toUpperCase ()) !=
305334 null )
306335 .toList ();
307336 }
308337
309338 void showCountryCodePickerDialog () async {
310339 final item = await showDialog (
311- barrierColor: widget.barrierColor ?? Colors .grey.withOpacity ( 0.5 ),
340+ barrierColor: widget.barrierColor ?? Colors .grey.withAlpha ( 128 ),
312341 context: context,
313342 builder: (context) => Center (
314343 child: Dialog (
0 commit comments