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
|
||||
|
||||
|
||||
@@ -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 WidgetBuilder emptySearchBuilder;
|
||||
final Function(CountryCode) builder;
|
||||
final bool enabled;
|
||||
final TextOverflow textOverflow;
|
||||
|
||||
/// shows the name of the country instead of the dialcode
|
||||
final bool showOnlyCountryWhenClosed;
|
||||
@@ -56,6 +58,8 @@ class CountryCodePicker extends StatefulWidget {
|
||||
this.showFlag = true,
|
||||
this.builder,
|
||||
this.flagWidth = 32.0,
|
||||
this.enabled = true,
|
||||
this.textOverflow = TextOverflow.ellipsis,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -91,27 +95,26 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
||||
else {
|
||||
_widget = FlatButton(
|
||||
padding: widget.padding,
|
||||
onPressed: _showSelectionDialog,
|
||||
onPressed: widget.enabled ? _showSelectionDialog : null,
|
||||
child: Flex(
|
||||
direction: Axis.horizontal,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
widget.showFlag
|
||||
? Flexible(
|
||||
flex: widget.alignLeft ? 0 : 1,
|
||||
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
||||
child: Padding(
|
||||
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',
|
||||
width: widget.flagWidth,
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
if (widget.showFlag)
|
||||
Flexible(
|
||||
flex: widget.alignLeft ? 0 : 1,
|
||||
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
||||
child: Padding(
|
||||
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',
|
||||
width: widget.flagWidth,
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
||||
child: Text(
|
||||
@@ -119,6 +122,7 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
||||
? selectedItem.toCountryStringOnly(context)
|
||||
: selectedItem.toString(),
|
||||
style: widget.textStyle ?? Theme.of(context).textTheme.button,
|
||||
overflow: widget.textOverflow,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user