Merge pull request #78 from imtoori/hotfix/showFlag
fix showflagdialog and main to override the showflag property
This commit is contained in:
@@ -38,9 +38,8 @@ class _MyAppState extends State<MyApp> {
|
|||||||
// Initial selection and favorite can be one of code ('IT') OR dial_code('+39')
|
// Initial selection and favorite can be one of code ('IT') OR dial_code('+39')
|
||||||
initialSelection: 'IT',
|
initialSelection: 'IT',
|
||||||
favorite: ['+39', 'FR'],
|
favorite: ['+39', 'FR'],
|
||||||
showFlag: false,
|
|
||||||
countryFilter: ['IT', 'FR'],
|
countryFilter: ['IT', 'FR'],
|
||||||
showFlagDialog: true,
|
showFlagDialog: false,
|
||||||
comparator: (a, b) => b.name.compareTo(a.name),
|
comparator: (a, b) => b.name.compareTo(a.name),
|
||||||
//Get the country information relevant to the initial selection
|
//Get the country information relevant to the initial selection
|
||||||
onInit: (code) =>
|
onInit: (code) =>
|
||||||
@@ -53,14 +52,14 @@ class _MyAppState extends State<MyApp> {
|
|||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: CountryCodePicker(
|
child: CountryCodePicker(
|
||||||
onChanged: print,
|
onChanged: print,
|
||||||
|
hideMainText: true,
|
||||||
|
showFlagMain: true,
|
||||||
|
showFlag: false,
|
||||||
initialSelection: 'TF',
|
initialSelection: 'TF',
|
||||||
hideSearch: true,
|
hideSearch: true,
|
||||||
showCountryOnly: true,
|
showCountryOnly: true,
|
||||||
showOnlyCountryWhenClosed: true,
|
showOnlyCountryWhenClosed: true,
|
||||||
alignLeft: true,
|
alignLeft: true,
|
||||||
builder: (countryCode) {
|
|
||||||
return Text('${countryCode.code}');
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ class CountryCodePicker extends StatefulWidget {
|
|||||||
/// shows the flag
|
/// shows the flag
|
||||||
final bool showFlag;
|
final bool showFlag;
|
||||||
|
|
||||||
|
final bool hideMainText;
|
||||||
|
|
||||||
final bool showFlagMain;
|
final bool showFlagMain;
|
||||||
|
|
||||||
final bool showFlagDialog;
|
final bool showFlagDialog;
|
||||||
@@ -71,6 +73,7 @@ class CountryCodePicker extends StatefulWidget {
|
|||||||
this.alignLeft = false,
|
this.alignLeft = false,
|
||||||
this.showFlag = true,
|
this.showFlag = true,
|
||||||
this.showFlagDialog,
|
this.showFlagDialog,
|
||||||
|
this.hideMainText = false,
|
||||||
this.showFlagMain,
|
this.showFlagMain,
|
||||||
this.builder,
|
this.builder,
|
||||||
this.flagWidth = 32.0,
|
this.flagWidth = 32.0,
|
||||||
@@ -132,7 +135,9 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
direction: Axis.horizontal,
|
direction: Axis.horizontal,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (widget.showFlag || (widget.showFlagMain == true))
|
if (widget.showFlagMain != null
|
||||||
|
? widget.showFlagMain
|
||||||
|
: widget.showFlag)
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: widget.alignLeft ? 0 : 1,
|
flex: widget.alignLeft ? 0 : 1,
|
||||||
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
||||||
@@ -147,16 +152,17 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Flexible(
|
if (!widget.hideMainText)
|
||||||
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
Flexible(
|
||||||
child: Text(
|
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
||||||
widget.showOnlyCountryWhenClosed
|
child: Text(
|
||||||
? selectedItem.toCountryStringOnly()
|
widget.showOnlyCountryWhenClosed
|
||||||
: selectedItem.toString(),
|
? selectedItem.toCountryStringOnly()
|
||||||
style: widget.textStyle ?? Theme.of(context).textTheme.button,
|
: selectedItem.toString(),
|
||||||
overflow: widget.textOverflow,
|
style: widget.textStyle ?? Theme.of(context).textTheme.button,
|
||||||
|
overflow: widget.textOverflow,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -231,7 +237,9 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
searchDecoration: widget.searchDecoration,
|
searchDecoration: widget.searchDecoration,
|
||||||
searchStyle: widget.searchStyle,
|
searchStyle: widget.searchStyle,
|
||||||
textStyle: widget.dialogTextStyle,
|
textStyle: widget.dialogTextStyle,
|
||||||
showFlag: widget.showFlag || (widget.showFlagDialog == true),
|
showFlag: widget.showFlagDialog != null
|
||||||
|
? widget.showFlagDialog
|
||||||
|
: widget.showFlag,
|
||||||
flagWidth: widget.flagWidth,
|
flagWidth: widget.flagWidth,
|
||||||
size: widget.dialogSize,
|
size: widget.dialogSize,
|
||||||
hideSearch: widget.hideSearch,
|
hideSearch: widget.hideSearch,
|
||||||
|
|||||||
Reference in New Issue
Block a user