Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More options: preselect a currency , and multiselect several currencies #9

Open
giorgio79 opened this issue Jan 22, 2021 · 5 comments

Comments

@giorgio79
Copy link

Would be nice to have a preselect array option, so one or more currencies can be preselected.
I am working on an app that has a currency selector and do some geolocation magic, and preselect the currency based on user geolocationn https://play.google.com/store/apps/details?id=com.cashtic

Also, the capability to multiselect would be great too.

@giorgio79
Copy link
Author

giorgio79 commented Jan 22, 2021

If anyone needs this functionality here is the code for getting user currency by location. It needs the geolocator and Google Maps api for reverse geocoding

//https://pub.dev/documentation/geocoding/latest/geocoding/placemarkFromCoordinates.html
      userGeolocatorPlacemark = await placemarkFromCoordinates(
          globals.geolocatorPosition.latitude,
          globals.geolocatorPosition.longitude);

      //get currency code for country
      //https://stackoverflow.com/questions/58766133/how-to-get-currency-and-currency-symbol-in-flutter-by-country-code
      userCurrencyByLocationCountry = CurrencyPickerUtils.getCountryByIsoCode(
              userGeolocatorPlacemark[0].isoCountryCode)
          .currencyCode;

@Daniel-Ioannou
Copy link
Owner

@giorgio79 I'm not sure what you mean preselected currencies, package dose not keep the selected currency, it only return the selected currency through onSelect callback.

If you want to show one or more currencies at the top of the list you can use favorite parameter:

   showCurrencyPicker(
     context: context,
     onSelect: (Currency currency) {
       print('Select currency: ${currency.name}');
     },
     favorite: <String> ['EUR', 'GBP', 'USD'],
   );

@giorgio79
Copy link
Author

Yeah, so if someone selects values and then the app saves it to Firebase or some storage, the next time the user edits the selected currencies, the saved values could be preloaded...

@voivoed
Copy link

voivoed commented Mar 19, 2021

@giorgio79 the way I handled this on my app was to put the previously selected currency as a favorite, so it shows at the top of the list in a separate box right under the search box. The user can just tap it again right away.

@MLZ91
Copy link

MLZ91 commented Dec 13, 2021

A preselected currency is possible right now but i have to use an ugly workaround. It would be nice if you could make currencies.dart available through a getter so we could set a new/initial Currency easily.

To make clear what preselected means: I have a button that shows a currency, the user can click it and change it to a different currency if he wants to. This button uses the currency_picker Currency class for getting the symbol and to draw the flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants