salim-lachdhaf / searchable_dropdown

Simple and robust Dropdown with item search feature, making it possible to use an offline item list or filtering URL for easy customization.
MIT License
326 stars 316 forks source link

mode, showSearchBox, searchFileDecorator, dropdownButtonBuilder, and popupItemBuilder aren't defined. #637

Closed steve3p0 closed 2 months ago

steve3p0 commented 2 months ago

Describe the bug When I try to instantiate a DropdownSearch widget in a page in my Flutter web app, several parameters of Dropdownsearch are undefined. I am using IntelliJ for Flutter development on Ubuntu 20.04. Here is a list of compile errors. These undefined parameters are also underlined in my code (but DropdownSearch and other params are not). It is very odd to me.

The named parameter 'mode' isn't defined. The await expression can only be used in an async function. The named parameter 'showSearchBox' isn't defined. The named parameter 'searchFieldDecorator' isn't defined. The named parameter 'dropdownButtonBuilder' isn't defined. The named parameter 'popupItemBuilder' isn't defined.

This app compiles and otherwise runs fine without the DropdownSearch widget.

To Reproduce I added this line to my public.yaml dropdown_search: ^5.0.6

And I am attempted to use this code in a widget build method:


  DropdownSearch<Provider>
  (

    mode: Mode.MENU, // or BOTTOM_SHEET
    //items: await getMtProviders(),
    items: **getMtProviders**(),
    selectedItem: _selectedProvider,
    onChanged: (provider) => setState(() => _selectedProvider = provider),
    **showSearchBox**: true,
    **searchFieldDecorator**: const InputDecoration(
      contentPadding: EdgeInsets.fromLTRB(12, 16, 12, 16),
      hintText: "Search provider",
      hintStyle: TextStyle(color: Colors.grey),
    ),
    **dropdownButtonBuilder**: (context, selectedItem) => selectedItem == null
        ? const Text("Select a Provider")
        : Text(
            selectedItem.name,
            style: const TextStyle(color: Colors.black),
          ),
    **popupItemBuilder**: (context, item, isSelected) => ListTile(
      leading: CircleAvatar(
        backgroundImage: NetworkImage(item.imageUrl),
      ),
      title: Text(item.name),
      selected: isSelected,
    ),
  )

Expected behavior I don't expect to see these errors.

Screenshots Screenshot from 2024-04-25 22-25-51

Dev environment

For web development: