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 ## 1.3.0
- Add `flagWidth` property
## 1.3.0
- Fixed selection dialog length - Fixed selection dialog length
- Added i18n with `CountryLocalizations` - Added i18n with `CountryLocalizations`

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
name: country_code_picker 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 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 homepage: https://github.com/Salvatore-Giordano/CountryCodePicker
environment: environment: