Merge branch 'master' into feature/styleable-search-field
This commit is contained in:
@@ -18,6 +18,16 @@ class CountryCodePicker extends StatefulWidget {
|
||||
final TextStyle searchStyle;
|
||||
final WidgetBuilder emptySearchBuilder;
|
||||
|
||||
/// shows the name of the country instead of the dialcode
|
||||
final bool showOnlyCountryWhenClosed;
|
||||
|
||||
/// aligns the flag and the Text left
|
||||
///
|
||||
/// additionally this option also fills the available space of the widget.
|
||||
/// this is especially usefull in combination with [showOnlyCountryWhenClosed],
|
||||
/// because longer countrynames are displayed in one line
|
||||
final bool alignLeft;
|
||||
|
||||
CountryCodePicker({
|
||||
this.onChanged,
|
||||
this.initialSelection,
|
||||
@@ -28,6 +38,8 @@ class CountryCodePicker extends StatefulWidget {
|
||||
this.searchDecoration = const InputDecoration(),
|
||||
this.searchStyle,
|
||||
this.emptySearchBuilder,
|
||||
this.showOnlyCountryWhenClosed = false,
|
||||
this.alignLeft = false,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -61,8 +73,12 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
flex: widget.alignLeft ? 0 : 1,
|
||||
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 16.0),
|
||||
padding: widget.alignLeft
|
||||
? const EdgeInsets.only(right: 16.0, left: 8.0)
|
||||
: const EdgeInsets.only(right: 16.0),
|
||||
child: Image.asset(
|
||||
selectedItem.flagUri,
|
||||
package: 'country_code_picker',
|
||||
@@ -71,8 +87,9 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
||||
child: Text(
|
||||
widget.showCountryOnly
|
||||
widget.showOnlyCountryWhenClosed
|
||||
? selectedItem.toCountryStringOnly()
|
||||
: selectedItem.toString(),
|
||||
style: widget.textStyle ?? Theme.of(context).textTheme.button,
|
||||
|
||||
Reference in New Issue
Block a user