pass codes in constructor

This commit is contained in:
alfredo-handcash
2021-05-13 10:05:46 +02:00
parent 803d41cf6d
commit e1098ee6c7

View File

@@ -80,6 +80,10 @@ class CountryCodePicker extends StatefulWidget {
/// [BoxDecoration] for the flag image
final Decoration? flagDecoration;
/// An optional argument for inject list of countries
/// with customized codes.
final List<Map<String, dynamic>> countryList;
CountryCodePicker({
this.onChanged,
this.onInit,
@@ -113,12 +117,13 @@ class CountryCodePicker extends StatefulWidget {
this.dialogSize,
this.dialogBackgroundColor,
this.closeIcon = const Icon(Icons.close),
this.countryList = codes,
Key? key,
}) : super(key: key);
@override
State<StatefulWidget> createState() {
List<Map> jsonList = codes;
List<Map> jsonList = countryList;
List<CountryCode> elements = jsonList
.map((json) => CountryCode.fromJson(json as Map<String, dynamic>))