add flagWidth prop

This commit is contained in:
Salvatore Giordano
2020-03-08 23:01:56 +01:00
parent 2a35d65e65
commit 4b0ff287f9
4 changed files with 24 additions and 11 deletions

View File

@@ -1,5 +1,9 @@
## 1.3.0
- Add `flagWidth` property
## 1.3.0
- Fixed selection dialog length
- Added i18n with `CountryLocalizations`

View File

@@ -36,6 +36,9 @@ class CountryCodePicker extends StatefulWidget {
/// contains the country codes to load only the specified countries.
final List<String> countryFilter;
/// Width of the flag images
final double flagWidth;
CountryCodePicker({
this.onChanged,
this.onInit,
@@ -52,6 +55,7 @@ class CountryCodePicker extends StatefulWidget {
this.alignLeft = false,
this.showFlag = true,
this.builder,
this.flagWidth = 32.0,
});
@override
@@ -103,7 +107,7 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
child: Image.asset(
selectedItem.flagUri,
package: 'country_code_picker',
width: 32.0,
width: widget.flagWidth,
),
),
)
@@ -177,6 +181,7 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
searchDecoration: widget.searchDecoration,
searchStyle: widget.searchStyle,
showFlag: widget.showFlag,
flagWidth: widget.flagWidth,
),
).then((e) {
if (e != null) {

View File

@@ -9,18 +9,22 @@ class SelectionDialog extends StatefulWidget {
final TextStyle searchStyle;
final WidgetBuilder emptySearchBuilder;
final bool showFlag;
final double flagWidth;
/// elements passed as favorite
final List<CountryCode> favoriteElements;
SelectionDialog(this.elements, this.favoriteElements,
{Key key,
this.showCountryOnly,
this.emptySearchBuilder,
InputDecoration searchDecoration = const InputDecoration(),
this.searchStyle,
this.showFlag})
: assert(searchDecoration != null, 'searchDecoration must not be null!'),
SelectionDialog(
this.elements,
this.favoriteElements, {
Key key,
this.showCountryOnly,
this.emptySearchBuilder,
InputDecoration searchDecoration = const InputDecoration(),
this.searchStyle,
this.showFlag,
this.flagWidth = 32,
}) : assert(searchDecoration != null, 'searchDecoration must not be null!'),
this.searchDecoration =
searchDecoration.copyWith(prefixIcon: Icon(Icons.search)),
super(key: key);
@@ -97,7 +101,7 @@ class _SelectionDialogState extends State<SelectionDialog> {
child: Image.asset(
e.flagUri,
package: 'country_code_picker',
width: 32.0,
width: widget.flagWidth,
),
),
),

View File

@@ -1,6 +1,6 @@
name: country_code_picker
description: A flutter package for showing a country code selector. In addition it gives the possibility to select a list of favorites countries, as well as to search using a simple searchbox
version: 1.3.0
version: 1.3.1
homepage: https://github.com/Salvatore-Giordano/CountryCodePicker
environment: