Skip to content

Commit

Permalink
V2.0.5
Browse files Browse the repository at this point in the history
Merge pull request #32 from Daniel-Ioannou/v2.0.5
  • Loading branch information
Daniel-Ioannou authored May 31, 2021
2 parents 3456694 + 7871e5d commit 9975aad
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 31 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
## [2.0.5] - 31 May 2021
* Add styling options for the border-radius and the search field.
```Dart
showCountryPicker(
context: context,
countryListTheme: CountryListThemeData(
// Optional. Sets the border radius for the bottomsheet.
borderRadius: BorderRadius.only(
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0),
),
// Optional. Styles the search field.
inputDecoration: InputDecoration(
labelText: 'Search',
hintText: 'Start typing to search',
prefixIcon: const Icon(Icons.search),
border: OutlineInputBorder(
borderSide: BorderSide(
color: const Color(0xFF8C98A8).withOpacity(0.2),
),
),
),
),
onSelect: (Country country) => print('Select country: ${country.displayName}'),
);
```
## [2.0.4] - 12 Apr 2021
* Add `CountryParser`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A flutter package to select a country from a list of countries.
Add the package to your pubspec.yaml:

```yaml
country_picker: ^2.0.4
country_picker: ^2.0.5
```
In your dart file, import the library:
Expand Down
39 changes: 28 additions & 11 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A flutter package to select a country from a list of countries.
Add the package to your pubspec.yaml:

```yaml
country_picker: ^2.0.4
country_picker: ^2.0.5
```
In your dart file, import the library:
Expand All @@ -22,11 +22,11 @@ A flutter package to select a country from a list of countries.
Show country picker using `showCountryPicker`:
```Dart
showCountryPicker(
context: context,
showPhoneCode: true, // optional. Shows phone code before the country name.
onSelect: (Country country) {
print('Select country: ${country.displayName}');
},
context: context,
showPhoneCode: true, // optional. Shows phone code before the country name.
onSelect: (Country country) {
print('Select country: ${country.displayName}');
},
);
```

Expand All @@ -50,17 +50,33 @@ MaterialApp(
```

### Parameters:
* `onSelect`: Called when a country is select. The country picker passes the new value to the callback (required)
* `onClosed`: Called when CountryPicker is dismiss, whether a country is selected or not (optional).
* `showPhoneCode`: Can be used to to show phone code before the country name.
* `countryListTheme`: Can be used to customizing the country list bottom sheet. (optional).
* `onSelect`: Called when a country is selected. The country picker passes the new value to the callback (required)
* `onClosed`: Called when CountryPicker is dismissed, whether a country is selected or not (optional).
* `showPhoneCode`: Can be used to show phone code before the country name.
* `countryListTheme`: Can be used to customize the country list's bottom sheet and widgets that lie within it. (optional).
```Dart
showCountryPicker(
context: context,
countryListTheme: CountryListThemeData(
flagSize: 25,
backgroundColor: Colors.white,
textStyle: TextStyle(fontSize: 16, color: Colors.blueGrey),
//Optional. Sets the border radius for the bottomsheet.
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0),
topRight: Radius.circular(20.0),
),
//Optional. Styles the search field.
inputDecoration: InputDecoration(
labelText: 'Search',
hintText: 'Start typing to search',
prefixIcon: const Icon(Icons.search),
border: OutlineInputBorder(
borderSide: BorderSide(
color: const Color(0xFF8C98A8).withOpacity(0.2),
),
),
),
),
onSelect: (Country country) => print('Select country: ${country.displayName}'),
);
Expand All @@ -73,9 +89,10 @@ MaterialApp(
onSelect: (Country country) => print('Select country: ${country.displayName}'),
);
```
* `countryFilter`: Can be used to uses filter the countries list (optional).
* `countryFilter`: Can be used to filter the countries list (optional).
- It takes a list of country code(iso2).
- Can't provide both exclude and countryFilter


## Contributions
Contributions of any kind are more than welcome! Feel free to fork and improve country_code_picker in any way you want, make a pull request, or open an issue.
10 changes: 5 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ class HomePage extends StatelessWidget {
onSelect: (Country country) {
print('Select country: ${country.displayName}');
},
//Optional. Sets the theme for the country list picker.
// Optional. Sets the theme for the country list picker.
countryListTheme: CountryListThemeData(
//Optional. Sets the border radius for the bottomsheet.
// Optional. Sets the border radius for the bottomsheet.
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0),
topRight: Radius.circular(20.0),
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0),
),
//Optional. Styles the search field.
// Optional. Styles the search field.
inputDecoration: InputDecoration(
labelText: 'Search',
hintText: 'Start typing to search',
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.6.0"
version: "2.6.1"
boolean_selector:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion lib/country_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void showCountryPicker({
List<String>? exclude,
List<String>? countryFilter,
bool showPhoneCode = false,
CountryListThemeData? countryListTheme = const CountryListThemeData(),
CountryListThemeData? countryListTheme,
// InputDecoration? inputDecoration
}) {
assert(exclude == null || countryFilter == null,
Expand Down
22 changes: 15 additions & 7 deletions lib/src/country_list_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ void showCountryListBottomSheet({
}

Widget _builder(
BuildContext context,
ValueChanged<Country> onSelect,
List<String>? exclude,
List<String>? countryFilter,
bool showPhoneCode,
CountryListThemeData? countryListTheme) {
BuildContext context,
ValueChanged<Country> onSelect,
List<String>? exclude,
List<String>? countryFilter,
bool showPhoneCode,
CountryListThemeData? countryListTheme,
) {
final device = MediaQuery.of(context).size.height;
final statusBarHeight = MediaQuery.of(context).padding.top;
final height = device - (statusBarHeight + (kToolbarHeight / 1.5));
Expand All @@ -51,11 +52,18 @@ Widget _builder(
}
}

final BorderRadius _borderRadius = countryListTheme?.borderRadius ??
const BorderRadius.only(
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0),
);

print('countryListTheme: $countryListTheme');
return Container(
height: height,
decoration: BoxDecoration(
color: _backgroundColor,
borderRadius: countryListTheme?.borderRadius,
borderRadius: _borderRadius,
),
child: CountryListView(
onSelect: onSelect,
Expand Down
5 changes: 1 addition & 4 deletions lib/src/country_list_theme_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ class CountryListThemeData {
this.textStyle,
this.flagSize,
this.inputDecoration,
this.borderRadius = const BorderRadius.only(
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0),
),
this.borderRadius,
});
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: country_picker
description: A flutter package to select a country from a list of countries.

version: 2.0.4
version: 2.0.5

homepage: https://github.com/Daniel-Ioannou
repository: https://github.com/Daniel-Ioannou/flutter_country_picker
Expand Down

0 comments on commit 9975aad

Please sign in to comment.