showCurrencyPicker function

void showCurrencyPicker({
  1. required BuildContext context,
  2. required ValueChanged<Currency> onSelect,
  3. List<String>? favorite,
  4. List<String>? currencyFilter,
  5. bool showSearchField = true,
  6. bool showFlag = true,
  7. bool showCurrencyName = true,
  8. bool showCurrencyCode = true,
  9. bool useRootNavigator = false,
  10. ScrollPhysics? physics,
  11. CurrencyPickerThemeData? theme,
  12. @Deprecated('Use inputDecoration instead. ' 'This feature was deprecated after v2.0.18.') String? searchHint,
})

Show currency picker

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).

currencyFilter: Can be used to uses filter the Currency list (optional).

favorite: The Currencies that will appear at the top of the list (optional).

theme: can be used to customizing the country list bottom sheet (optional).

useRootNavigator: ensures that the root navigator is used to display the BottomSheet when set to true. This is useful in the case that a modal BottomSheet needs to be displayed above all other content but the caller is inside another Navigator.

This example demonstrates how to use showCurrencyPicker

showCurrencyPicker(
   context: context,
   showFlag: true,
   showCurrencyName: true,
   showCurrencyCode: true,
   onSelect: (Currency currency) {
      print('Select currency: ${currency.name}');
   },
   currencyFilter: <String>['EUR', 'GBP', 'USD', 'AUD', 'CAD', 'JPY', 'HKD', 'CHF', 'SEK', 'ILS'],
);

Implementation

void showCurrencyPicker({
  required BuildContext context,
  required ValueChanged<Currency> onSelect,
  List<String>? favorite,
  List<String>? currencyFilter,
  bool showSearchField = true,
  bool showFlag = true,
  bool showCurrencyName = true,
  bool showCurrencyCode = true,
  bool useRootNavigator = false,
  ScrollPhysics? physics,
  CurrencyPickerThemeData? theme,
  @Deprecated(
    'Use inputDecoration instead. '
        'This feature was deprecated after v2.0.18.',
  )
  String? searchHint,
}) {
  assert(
    showCurrencyName || showCurrencyCode,
    'showCurrencyName and showCurrencyCode cannot be both false',
  );
  currency_list.showCurrencyListBottomSheet(
    context: context,
    onSelect: onSelect,
    showSearchField: showSearchField,
    searchHint: searchHint,
    showFlag: showFlag,
    showCurrencyName: showCurrencyName,
    showCurrencyCode: showCurrencyCode,
    useRootNavigator: useRootNavigator,
    favorite: favorite,
    currencyFilter: currencyFilter,
    theme: theme,
    physics: physics,
  );
}