项目作者: Daniel-Ioannou

项目描述 :
A flutter package to select a currency from a list of currencies.
高级语言: Dart
项目地址: git://github.com/Daniel-Ioannou/flutter_currency_picker.git
创建时间: 2020-10-22T16:10:21Z
项目社区:https://github.com/Daniel-Ioannou/flutter_currency_picker

开源协议:MIT License

下载


Currency picker

pub package

A flutter package to select a currency from a list of currencies.

n1

Getting Started

Add the package to your pubspec.yaml:

  1. currency_picker: ^2.0.21

In your dart file, import the library:

  1. import 'package:currency_picker/currency_picker.dart';

Show currency picker using showCurrencyPicker:

  1. showCurrencyPicker(
  2. context: context,
  3. showFlag: true,
  4. showCurrencyName: true,
  5. showCurrencyCode: true,
  6. onSelect: (Currency currency) {
  7. print('Select currency: ${currency.name}');
  8. },
  9. );

Parameters:

  • onSelect: Called when a currency is select. The currency picker passes the new value to the callback (required)
  • showFlag: Shows flag for each currency. Default value true (optional).
  • searchHint: Option to customize hint of the search TextField (optional).
  • showCurrencyName: Option to show/hide the currency name, default value true (optional).
  • showCurrencyCode: Option to show/hide the currency code, default value true (optional).
  • showSearchField: Option to show/hide the search TextField, default value true (optional).
  • currencyFilter: Can be used to filter the Currency list (optional).
    1. showCurrencyPicker(
    2. context: context,
    3. onSelect: (Currency currency) {
    4. print('Select currency: ${currency.name}');
    5. },
    6. currencyFilter: <String>['EUR', 'GBP', 'USD', 'AUD', 'CAD', 'JPY', 'HKD', 'CHF', 'SEK', 'ILS'],
    7. );
  • favorite: Can be used to show the favorite currencies at the top of the list (optional).
  • theme: Can be used to customizing the currency list bottom sheet. (optional).
    1. showCurrencyPicker(
    2. context: context,
    3. theme: CurrencyPickerThemeData(
    4. flagSize: 25,
    5. titleTextStyle: TextStyle(fontSize: 17),
    6. subtitleTextStyle: TextStyle(fontSize: 15, color: Theme.of(context).hintColor),
    7. bottomSheetHeight: MediaQuery.of(context).size.height / 2,
    8. //Optional. Styles the search field.
    9. inputDecoration: InputDecoration(
    10. labelText: 'Search',
    11. hintText: 'Start typing to search',
    12. prefixIcon: const Icon(Icons.search),
    13. border: OutlineInputBorder(
    14. borderSide: BorderSide(
    15. color: const Color(0xFF8C98A8).withOpacity(0.2),
    16. ),
    17. ),
    18. ),
    19. ),
    20. onSelect: (Currency currency) => print('Select currency: ${currency.name}'),
    21. );

    Contributions

    Contributions of any kind are more than welcome! Feel free to fork and improve currency_picker in any way you want, make a pull request, or open an issue.