add enabled and textOverflow
This commit is contained in:
@@ -1,4 +1,8 @@
|
|||||||
## 1.3.0
|
## 1.3.2
|
||||||
|
|
||||||
|
- Add `enable` property in order to use the disable the button
|
||||||
|
|
||||||
|
## 1.3.1
|
||||||
|
|
||||||
- Add `flagWidth` property
|
- Add `flagWidth` property
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,21 @@ class _MyAppState extends State<MyApp> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 100,
|
||||||
|
height: 60,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: CountryCodePicker(
|
||||||
|
enabled: false,
|
||||||
|
onChanged: print,
|
||||||
|
initialSelection: 'TF',
|
||||||
|
showCountryOnly: true,
|
||||||
|
showOnlyCountryWhenClosed: true,
|
||||||
|
favorite: ['+39', 'FR'],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ class CountryCodePicker extends StatefulWidget {
|
|||||||
final TextStyle searchStyle;
|
final TextStyle searchStyle;
|
||||||
final WidgetBuilder emptySearchBuilder;
|
final WidgetBuilder emptySearchBuilder;
|
||||||
final Function(CountryCode) builder;
|
final Function(CountryCode) builder;
|
||||||
|
final bool enabled;
|
||||||
|
final TextOverflow textOverflow;
|
||||||
|
|
||||||
/// shows the name of the country instead of the dialcode
|
/// shows the name of the country instead of the dialcode
|
||||||
final bool showOnlyCountryWhenClosed;
|
final bool showOnlyCountryWhenClosed;
|
||||||
@@ -56,6 +58,8 @@ class CountryCodePicker extends StatefulWidget {
|
|||||||
this.showFlag = true,
|
this.showFlag = true,
|
||||||
this.builder,
|
this.builder,
|
||||||
this.flagWidth = 32.0,
|
this.flagWidth = 32.0,
|
||||||
|
this.enabled = true,
|
||||||
|
this.textOverflow = TextOverflow.ellipsis,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -91,27 +95,26 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
else {
|
else {
|
||||||
_widget = FlatButton(
|
_widget = FlatButton(
|
||||||
padding: widget.padding,
|
padding: widget.padding,
|
||||||
onPressed: _showSelectionDialog,
|
onPressed: widget.enabled ? _showSelectionDialog : null,
|
||||||
child: Flex(
|
child: Flex(
|
||||||
direction: Axis.horizontal,
|
direction: Axis.horizontal,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
widget.showFlag
|
if (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,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: widget.alignLeft
|
padding: widget.alignLeft
|
||||||
? const EdgeInsets.only(right: 16.0, left: 8.0)
|
? const EdgeInsets.only(right: 16.0, left: 8.0)
|
||||||
: const EdgeInsets.only(right: 16.0),
|
: const EdgeInsets.only(right: 16.0),
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
selectedItem.flagUri,
|
selectedItem.flagUri,
|
||||||
package: 'country_code_picker',
|
package: 'country_code_picker',
|
||||||
width: widget.flagWidth,
|
width: widget.flagWidth,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
: Container(),
|
|
||||||
Flexible(
|
Flexible(
|
||||||
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -119,6 +122,7 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
? selectedItem.toCountryStringOnly(context)
|
? selectedItem.toCountryStringOnly(context)
|
||||||
: selectedItem.toString(),
|
: selectedItem.toString(),
|
||||||
style: widget.textStyle ?? Theme.of(context).textTheme.button,
|
style: widget.textStyle ?? Theme.of(context).textTheme.button,
|
||||||
|
overflow: widget.textOverflow,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user