GithubHelp home page GithubHelp logo

altafc22 / csc_picker Goto Github PK

View Code? Open in Web Editor NEW
27.0 2.0 109.0 3.69 MB

A flutter package to display a country, states, and cities. In addition it gives the possibility to select a list of countries, States and Cities depends on Selected, also you can search country, state, and city all around the world.

License: BSD 3-Clause "New" or "Revised" License

Kotlin 0.66% Swift 0.83% Objective-C 0.08% Dart 98.43%
country city state picker dropdown flutter pacakge

csc_picker's Issues

OnCountryChanged, OnStateChanged, OnCityChanged does not get triggered

OnCountryChanged, OnStateChanged, OnCityChanged does not get triggered when setting the currentcountry, currentstate, currentcity.

I am setting the default values initially, so after the initial save, when I load the page I see the values setting correctly, but when I visit the page again, I see the default values

For Layout.vertical neither showStates=false nor showCities=false are respected

Describe the bug
When using Layout.vertical neither showStates=false nor showCities=false are respected.

To Reproduce
Steps to reproduce the behavior:

  1. Open example
  2. Go to line 55 and change to
///Enable disable state dropdown [OPTIONAL PARAMETER]
showStates: false,

/// Enable disable city drop down [OPTIONAL PARAMETER]
showCities: false,
layout: Layout.vertical,

Expected behavior
For vertical layouts you should be able to hide the cities or states.

Can not find city with country subordination

Describe the bug
Can not find Kyiv, Ukraine using widget. It exists in countries-states-cities-database, but probably the issue is that it's a city at the level of state.

To Reproduce
Steps to reproduce the behavior:

  1. Search for Ukraine in country field
  2. Search for Kyiv in state field
  3. There will be no Kyiv in states result, just Kyivska oblast
  4. If select Kyivska oblast - there will be Kyiv as a capitol also

Expected behavior
Kyiv should be found either on the level of state inside Ukraine country, or on the level of city under Ukraine -> Kyivska oblast state.

When added box decorations state and place dropdowns are in disable state all the time all

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Associate countries with their ISO codes

This package is the most useful available for selecting country/state/city, but does not associate ISO codes with countries. This would be an enormously helpful feature.

In City Name why it's give Unicode char.

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Sate is stored internally

Describe the bug
It's really more of a design issue that causes bugs when working with larger apps.

Selected State of the csc_picker is stored internally. This means that if the widget tree needs to be redrawn it will loose its selected state data. Example if the window is resized on desktop and the tree ordering changes.

It also means it's not possible to pre-populate the state if loading for example user account settings over a network connection. The only exposed initial option is defaultCountry.

A possible solution:
I think it would be good to adopt the Flutter convention of a "Controller" that holds on to the state, and a display widget that shows that state. Separating the different concerns.

A example is TextField, if you hold on to a reference to the TextEditingController even if the Widget tree is rebuilt the controller and the data it holds is still valid and can rebuild the widget without loosing the users place.

Show States/Cities Feature

Love the look of this plugin but it would be even better if you were able to configure it so that you can hide the State and City dropdowns if the relevant parameter is set to false. Is that something you'd consider adding?

Italian states are wrong

Italian states are completely wrong. Provinces, municipalities and states are mixed in the same picker.
Screenshot_20230804_123714~2
Screenshot_20230804_123723~2

Ability to create a customized UI

I was trying to replicate a design. But the design is different from what comes with this package. I can change border and all through decorations but I couldn't change the height of the dropdowns or the space between it.

Also I need to show only the state in vertical view only(i.e no country or city) but that's not possible.

showState = false doesn't work properly

Hi,

I need to be able to show only Countries and Cities lists but I found that showState = true/false flag does not work properly:

  • if to set layout: Layout.vertical then State dropdown list is shown regardless to the value of showState
  • if layout is not set and showState: false then Countries doprdown list is shown only (even if showCities is true);

I took a look on your source code in csc_picker.dart and found that when CSC widget is being built there is no check of showState/showCities at all when layout is vertical, and when layout is not set it shows Cities list only if showState is true.

Localization for names

I would like to be able to have the country names in the locale that I want, like if the local is 'es', then "United States" should be "Estados Unidos", and so on.

Or is there any way to achieve this right now it would be great!

Cities Are Called Twice

Some cities are called twice as shown in the picture. When I examine the CSV file in countries-states-cities-database, I see that it is created once, but it is called twice in the package.

Screenshot 2023-03-14 at 12 25 04

add config of enabled county list

Is your feature request related to a problem? Please describe.
some times our product don't supports all countries, and we have a list of supported counties, this request is to make the country list configurable of the county dropdown in this widget.

Describe the solution you'd like
Supports a config property which accepts a list of selectable counties.

Describe alternatives you've considered
no

Additional context
no

selectedItemPadding

Look like you forgot to use selectedItemPadding in dropdown_with_search.dart.

FormField variant

Is your feature request related to a problem? Please describe.
I'm using this widget in a form, and I need to be able to validate the values on Form validation

Describe the solution you'd like
Either to have validator, onChanged, onSaved etc properties added to the existing widget or a CSCPickerFormField variant with all form properties.

CSCPickerState._onSelectedCountry

E/flutter (20371): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
E/flutter (20371): #0 CSCPickerState._onSelectedCountry. (package:csc_picker/csc_picker.dart:741:35)
E/flutter (20371): #1 State.setState (package:flutter/src/widgets/framework.dart:1109:30)
E/flutter (20371): #2 CSCPickerState._onSelectedCountry (package:csc_picker/csc_picker.dart:723:5)
E/flutter (20371): #3 CSCPickerState._setDefaultCountry (package:csc_picker/csc_picker.dart:618:7)
E/flutter (20371): #4 CSCPickerState.getCountries (package:csc_picker/csc_picker.dart:647:5)
E/flutter (20371):
E/flutter (20371):
carbon
carbon (1)

Customise box decoration/ text field

There is no method to adjust height and width of country, state and city box decorations. I have tried implementing Padding, SizedBox as well but it doesn't work. I cannot adjust height and width of box decoration according to my other input fields.

IMG_20210718_021346

Spelling mistakes

It says 'flat' instead of 'flag' in two spots. In the documentation and code comments.

Disable country dropdown

Hi, is it possible to lock the country drop down ?
For example I set a default country, then I just want to be able to select the state and the town from this default country already set by default.

Background Colors Still White In Dark Mode

Describe the bug
Background of fields are still white though in dark mode

To Reproduce
Steps to reproduce the behavior:

  1. Change to dark mode

Expected behavior
Background colors of the fields should change to a darker color or be derived from app theme

Screenshots
Screenshot_20210726-190700

Smartphone (please complete the following information):

  • Device: Samsung Note 10 Lite
  • OS: Android 11

Add config/property to filter countries

I can see the function added to filter country based on user input but not able to see the call for this function anywhere. Also not able to see any property to set the country filter criteria. Below existing function code in csc_picker.dart

///filter Country Data according to user input
Future<List<String?>> getCountryData(filter) async {

Please add config/property to set country filter. For example only show certain set of countries just like United State, Canada, etc.

Request: Method to customize default texts

Hello and thank you very much for developing this module, I have a small request to be able to customize the texts that are shown in the search boxes such as "State", "Search State", "Search Country" and "Search city" this would allow internationalization correctly these labels and increase the potential of this module. Thank you

Cannot store selected flag icon in database and how to change background of dropdown box ?

I'm trying to store the selected country flag in my database when ever a country is selected i can't able to see the country flag in my debug console as well as in my database why ? . How to change the dropdown box of country ,state ,city ? I want the dropdown box background as yellow and text inside it as white

Steps tried to reproduce:

CSCPicker(
 flagState: CountryFlag.SHOW_IN_DROP_DOWN_ONLY, // tried CountryFlag.ENABLE
);

country
country_box
bg

Editor : Visual studio code
Flutter version : 2.0.2

Fetching Saved Country,State,City from firestore and displaying to user

I am using version 0.2.6
I am trying to set the currentState and CurrentCity and CurrentCountry using setState((){
}); when fetching saved data from Firestore. now the problem is When i try to set the data i get this error " Unhandled Exception: setState() called after dispose(): CSCPickerState#a6452(lifecycle state: defunct, not mounted)
"
Is this expected behaviour or i am doing something wrong here

Can't Select Country nor State

Hi. I tried to use that tool but it gave error on picking screen. my code is:

                        layout: Layout.horizontal,
                        flagState: CountryFlag.ENABLE,
                        showStates: true,
                        showCities: true,
                        dropdownDecoration: kBoxDecorationStyle,
                          disabledDropdownDecoration: kBoxDecorationStyle,
                          onCountryChanged: (value) {
                          setState(() {
                            countryValue = value;
                          });
                          },
                        onStateChanged: (value) {
                          setState(() {
                            stateValue = value!;
                          });
                        },
                        onCityChanged: (value) {
                          setState(() {
                            cityValue = value!;
                          });
                        },
                        selectedItemStyle: TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
                        dropdownDialogRadius: 15.0,
                        searchBarRadius: 15.0,
                        dropdownItemStyle: TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
                      ),

The error is: 
```I/flutter ( 8694): countryChanged ๐Ÿ‡ฆ๐Ÿ‡ฑ    Albania null
E/flutter ( 8694): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Null check operator used on a null value
E/flutter ( 8694): #0      _RegisterScreenState.build.<anonymous closure>.<anonymous closure> (package:datingapp/screens/register.dart:242:47)
E/flutter ( 8694): #1      State.setState (package:flutter/src/widgets/framework.dart:1088:30)
E/flutter ( 8694): #2      _RegisterScreenState.build.<anonymous closure> (package:datingapp/screens/register.dart:241:27)
E/flutter ( 8694): #3      _CSCPickerState._onSelectedCountry.<anonymous closure> (package:csc_picker/csc_picker.dart:695:36)
E/flutter ( 8694): #4      State.setState (package:flutter/src/widgets/framework.dart:1088:30)
E/flutter ( 8694): #5      _CSCPickerState._onSelectedCountry (package:csc_picker/csc_picker.dart:682:5)
E/flutter ( 8694): #6      _CSCPickerState.countryDropdown.<anonymous closure> (package:csc_picker/csc_picker.dart:837:11)
E/flutter ( 8694): #7      DropdownWithSearch.build.<anonymous closure>.<anonymous closure> (package:csc_picker/dropdown_with_search.dart:53:22)
E/flutter ( 8694): #8      _rootRunUnary (dart:async/zone.dart:1362:47)
E/flutter ( 8694): #9      _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter ( 8694): <asynchronous suspension>
E/flutter ( 8694): 

Cities list does not appear if state list disabled

Describe the bug
The cities list does not appear if I disable the state selector

To Reproduce
set showStates: false and showCities: true

Expected behavior
I expect the widget to show the cities list that contains all the cities of the selected country

Update cities in country.json

There are countries that have wrong cities in "country.json". Instead in [https://countrystatecity.in/] appears the correct ones.

after clicking on close in modal the all dropdown resets its values

i have selected country india and state as gujrat and then i again go to country dropdown and then in modal i click on close then country and state then it resets its value to initial stage .... it should store the previous values

image

after clicking on close link in country modal

image

Missing town Stratford, New Zealand

The town of Stratford is missing from country New Zealand. State is "Taranaki Region".

Stratford NZ got it's name from Stratford in the U.K. - birthplace of William Shakespeare. Many of the streets in Stratford NZ are name after characters in Shakespeare plays.

Just north of Stratford is New Plymouth which got its name from Plymouth in the U.K.

STOPPED WORKING AFTER 3.7.3

Describe the bug
Error in IDE due to new flutter version.

Steps to reproduce the behavior:

  1. Upgrade Flutter

Expected behavior
No error should be shown.

Error: Undefined name 'DefaultCountry'. (Documentation) Try correcting the name to one that is defined, or defining the name.

Need Only country and state in country.json

Is your feature request related to a problem? Please describe.
the huge size of the file and huge build for application

Describe the solution you'd like
remove the city from the country.json

Allow CSCPicker to set previously selected values

Is your feature request related to a problem? Please describe.
There's currently no way to tell the CSCPicker that it should contain previously selected values.

Describe the solution you'd like
currentCountry, currentState, and currentCity values

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.