Skip to content

Commit

Permalink
Fix Lint warning
Browse files Browse the repository at this point in the history
  • Loading branch information
g123k committed Jul 8, 2024
1 parent 25bd541 commit ad78108
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class _CountrySelectorButton extends StatelessWidget {
child: AutoSizeText(
EmojiHelper.getEmojiByCountryCode(country.countryCode)!,
textAlign: TextAlign.center,
style: TextStyle(fontSize: IconTheme.of(context).size!),
style: TextStyle(fontSize: IconTheme.of(context).size),
),
)
else
Expand Down Expand Up @@ -292,8 +292,7 @@ class _CountrySelectorScreen extends StatelessWidget {
_CountrySelectorState? oldValue,
_CountrySelectorState currentValue,
) {
if (provider.autoValidate &&
oldValue is _CountrySelectorEditingState &&
if (oldValue is _CountrySelectorEditingState &&
currentValue is! _CountrySelectorEditingState &&
currentValue is _CountrySelectorLoadedState) {
WidgetsBinding.instance.addPostFrameCallback((_) {
Expand Down Expand Up @@ -444,10 +443,11 @@ class _CountrySelectorListState extends State<_CountrySelectorList> {
final Country? selectedCountry =
state.runtimeType == _CountrySelectorEditingState
? (state as _CountrySelectorEditingState).selectedCountry
: null;
: state.country;

final Iterable<Country> countries = _filterCountries(
state.countries,
state.country,
selectedCountry,
controller.text,
);
Expand Down Expand Up @@ -476,6 +476,7 @@ class _CountrySelectorListState extends State<_CountrySelectorList> {

Iterable<Country> _filterCountries(
List<Country> countries,
Country? userCountry,
Country? selectedCountry,
String? filter,
) {
Expand All @@ -485,6 +486,7 @@ class _CountrySelectorListState extends State<_CountrySelectorList> {

return countries.where(
(Country country) =>
country == userCountry ||
country == selectedCountry ||
country.name.toLowerCase().contains(
filter.toLowerCase(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ class _CountrySelectorProvider extends ValueNotifier<_CountrySelectorState> {
final _CountrySelectorLoadedState state =
value as _CountrySelectorLoadedState;

/// Reorder items
final List<Country> countries = state.countries;
_reorderCountries(countries, userCountryCode);

value = state.copyWith(
country: _getSelectedCountry(state.countries),
countries: countries,
);
}
}
Expand Down Expand Up @@ -183,7 +188,9 @@ class _CountrySelectorProvider extends ValueNotifier<_CountrySelectorState> {

/// Reorder countries alphabetically, bring user's locale country to top.
static void _reorderCountries(
List<Country> countries, String? userCountryCode) {
List<Country> countries,
String? userCountryCode,
) {
countries.sort(
(final Country a, final Country b) {
if (a.countryCode == userCountryCode) {
Expand Down

0 comments on commit ad78108

Please sign in to comment.