Giter Club home page Giter Club logo

flutter_country_picker's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

flutter_country_picker's Issues

Disabling the dropdown component

Currently there is no option to disable the country picker dropdown. In case if I have missed the doc, please point me to the same.

Country sorting issues

Country names are always ordered using their english names.

If the application uses another locale and shows the country names in a different language, the order of the countries is the same as if using english, with the result that the list shown is not ordered correctly.

Instance of a Country model by country code

is it possible to get Country object by passing country code?

e.g. after picking a country, i have some data like country code, and name.
now, how do I get (later) that very same object just by country code? without opening the picker, of course

Can't make a pre-selection

I have a user profile with his mobile number and want to show the ( flag +XX ) next to it.
but I'm not able to get the country object before the selection
can you help me with that please..

Search text style

Please add 'style' to the text search field
So I can add custom style to the search text field (color, font)

Bug of country code in Turkish localization

Discussed in #59

Originally posted by kuyucuburak January 10, 2022
Hi, country code of US should be US not ABD. Country code should not be changed according to localizations. The others seems unchanged. It seems this is just a bug. Right?

"ABD": "Amerika Birleşik Devletleri",

'BT' code is duplicate in tr.dart
The second BT should be IT

Display Country Only

Thank you for creating a very easy to implement Country Picker for Flutter.
I made showPhoneCode: false, and it does not display the phone code on the drop down list; however, it posts that data back to the context; United States (US) [+1], and I would rather have it show just show the Country when posting back after selection. Would it be possible to select only the country name from country.displayname?

Thanks again.

How to force language ?

I am able to see that the context has the appropriate language before calling the showCountryPicker function,

but within the CountryListView widget, I am no longer able to access the context.

I saw this by printing ${CountryLocalizations.of(context)?.countryName(countryCode: 'GB') before the call and receiving the correct value.

when I try printing this same value within the CountryListView widget , it prints a null value.

What am I doing wrong or is there an error ?

Thanks,

Flag emojis showing country letters instead of flags on windows

I am building a windows application that utilizes country pickers. My code is as follows:

class _CountryPickerButton extends StatefulWidget {
  const _CountryPickerButton();

  @override
  State<_CountryPickerButton> createState() => _CountryPickerButtonState();
}

class _CountryPickerButtonState extends State<_CountryPickerButton> {
  Country selectedCountry = Country.parse('Syria');

  @override
  Widget build(BuildContext context) {
    return TextFormField(
      maxLength: 10,
      inputFormatters: [FilteringTextInputFormatter.digitsOnly],
      keyboardType: TextInputType.number,
      decoration: InputDecoration(
        prefix: _buildPhoneButton(context),
        labelText: 'phone number',
        border: const OutlineInputBorder(),
      ),
    );
  }

  Widget _buildPhoneButton(BuildContext context) {
    return TextButton(
      child: Text('+${selectedCountry.phoneCode}'),
      onPressed: () => showCountryPicker(
        context: context,
        onSelect: (country) => setState(() => selectedCountry = country),
      ),
    );
  }
}

It's working okay on Android emulators:

phone

On windows, however, it's showing letters instead of flags:

windows

JSON import

Hi,

Would it be possible to have the the code to import a .json file instead of a list of countries, without the flag?

Thanks

Initial Country

How can i set Initial Country in textfield ? For eg. I have to fetch Country from API then i must have to pass some CountryCode arguments!!!!

Issues after upgrading to Flutter 2.5

/development/flutter/.pub-cache/git/country_pickers-f71243f09a21c9816b698c0b52c53ea9ce4e4779/lib/utils/my_alert_dialog.dart:108:46: Error: The getter 'title' isn't defined for the class 'TextTheme'.

  • 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' /development/flutter/packages/flutter/lib/src/material/text_theme.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'title'.
    style: Theme.of(context).textTheme.title,
    ^^^^^
    /development/flutter/.pub-cache/git/country_pickers-f71243f09a21c9816b698c0b52c53ea9ce4e4779/lib/utils/my_alert_dialog.dart:130:48: Error: The getter 'subhead' isn't defined for the class 'TextTheme'.
  • 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('/development/flutter/packages/flutter/lib/src/material/text_theme.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'subhead'.
    style: Theme.of(context).textTheme.subhead,
    ^^^^^^^

FAILURE: Build failed with an exception.

flutter doctor -v

[✓] Flutter (Channel stable, 2.5.3, on Mac OS X 10.15.7 19H15 darwin-x64, locale en-US)
• Flutter version 2.5.3 at /Users/xxxx/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 18116933e7 (5 days ago), 2021-10-15 10:46:35 -0700
• Engine revision d3ea636dc5
• Dart version 2.14.4

Get flag images on selected

Hi! Thanks for your great package! I was wondering if it was possible to extract the flag image once a country is selected? Thanks!

Multi language switching

How to set the name of a country to follow the international language settings inside the app by default instead of following the system

Expression has a void type

This expression has a type of 'void' so its value can't be used.
Try checking to see if you're using the correct API; there might be a function or call that returns void you didn't expect. Also check type parameters and variables which might also be void.dartuse_of_void_result

I get this error when I added
showCountryPicker(
context: context,
onSelect: (Country country) {
if (kDebugMode) {
print('Select country: ${country.displayName}');
}
},
),

Custom styling

Right now it's impossible to define custom colors for the pop-up

How to set width of countrypicker when using browser

Hello,
I'm using the country picker as follows:
GestureDetector( child: Icon(Icons.edit), onTap: () { showCountryPicker( context: context, onSelect: (Country country) { setState(() { currentCountry = country.displayNameNoCountryCode; }); }, ); }, )

When the country picker is shown, the width cannot be set so it takes the whole monitor screen size

Countries Flags (icons) not loaded / showing country code instead V2.0.22

country_picker: ^2.0.22

======== Exception caught by image resource service ================================================
The following Event$ object was thrown resolving an image frame:
[object Event]

When the exception was thrown, this was the stack:
Image provider: NetworkImage("https://www.countryflagicons.com/FLAT/64/AU.png", scale: 1)
Image key: NetworkImage("https://www.countryflagicons.com/FLAT/64/AU.png", scale: 1)

image

Localizations doesn't work

Hi. I've made an app that uses localizations, as described in the Flutter docs. I've tried to run the example project, and that implementation works. However, when implemented using the official Flutter guide, it doesn't work. I've added a complete runnable project that demonstrates this issue.

Other localized strings works as intended , but the static CountryLocalizations? of(BuildContext context) method in country_localizations.dart returns null, which means that none of the strings in the package are translated. I'm not completely sure what causes this issue, because the inner workings of the Flutter localizations still remains a mystery to me.

An example of a workaround fould be to return CountryLocalizations(Localizations.localeOf(context)) instead of Localizations.of<CountryLocalizations>(context, CountryLocalizations), but I don't know if this comes with some kind of cost. Thoughts?

we want mobile number length

we want mobile number length based on country like example if it India it has 10 digits so it will be useful for use restrict textfield lengths based on country

country localization for maximum Asian countries

Hello maintainers!
The country name translation and localizations are done very well in the package. But I couldn't find the country name localizations for most of the Asian countries [🇳🇵, 🇮🇳, 🇧🇹, 🇵🇰, 🇧🇩 ] including mine.
It would be much better to configure the localization feature for Asian countries too.
:)

nameLocalized throws LateInitialisationError

If the country is parsed from .parse(...) or .tryParse() accessing nameLocalized throws a LateInitialisationError.
Probably not an easy fix since a context is needed to get the localized name but maybe there is a way to do it.

Support for language

Is it possible to extend this project and also provide a language picker?
The use case is to provide flutter app translation support by selecting a language from the picker

Country name in French

Please, there is an error in nomination of Morocco in French

Morocco is Maroc in French not Moroc, can I control the nomination?

Add static utils method for default value

Following the example of a old similar library, you can add static methods
country_pickers

Example

  Country _selectedDialogCountry = CountryPickerUtils.Utils.getCountryByIsoCode('MF');

  void _openCountryPickerDialog() =>  showCountryPicker(
    context: context,
    //Optional.  Can be used to exclude(remove) one ore more country from the countries list (optional).
    // exclude: <String>['KN', 'MF'],
    favorite: <String>['SE, US'],
    //Optional. Shows phone code before the country name.
    showPhoneCode: true,
    onSelect: (Country country) {
      setState(() => _selectedDialogCountry = country);
    },
    // Optional. Sets the theme for the country list picker.
    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),
          ),
        ),
      ),
    ),
  );

   Text("+${_selectedDialogCountry.phoneCode}"), -> view user

change utils

   import 'country.dart';
import 'res/country_codes.dart';

class Utils {
  static List<Country> _countryList = countryCodes.map((country) => Country.from(json: country)).toList();

  static String countryCodeToEmoji(String countryCode) {
    // 0x41 is Letter A
    // 0x1F1E6 is Regional Indicator Symbol Letter A
    // Example :
    // firstLetter U => 20 + 0x1F1E6
    // secondLetter S => 18 + 0x1F1E6
    // See: https://en.wikipedia.org/wiki/Regional_Indicator_Symbol
    final int firstLetter = countryCode.codeUnitAt(0) - 0x41 + 0x1F1E6;
    final int secondLetter = countryCode.codeUnitAt(1) - 0x41 + 0x1F1E6;
    return String.fromCharCode(firstLetter) + String.fromCharCode(secondLetter);
  }

  static Country getCountryByIsoCode(String isoCode) {
    try {
      return _countryList.firstWhere((country) => country.countryCode.toLowerCase() == isoCode.toLowerCase(),
      );
    } catch (error) {
      throw Exception("The initialValue provided is not a supported iso code!");
    }
  }

}

Default Locale is null

When the locale is not supported, the plugin not return the deault one (english).
The returned value is null.

getting both the localized name and the English name of the country

I'm trying to store the name of the country in both Arabic and English,
I did setup supportedLocales and localizationsDelegates in MaterialApp,
when the app is set to Arabic local, getting the value with: "country.name" gives English name
and getting the value with: country.getTranslatedName(context) gives Arabic name, so that works, but if the app is in English local
both methods gives English name,
what should I do to get both English and Arabic name of the country when the app is in English local?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.