Coder Social home page Coder Social logo

esentis / multiple_search_selection Goto Github PK

View Code? Open in Web Editor NEW
12.0 1.0 13.0 3.11 MB

A highly customizable multiple selection widget with fuzzy search functionality.

Home Page: https://pub.dev/packages/multiple_search_selection

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

Kotlin 0.12% Swift 0.39% Objective-C 0.04% Dart 97.78% HTML 1.67%
flutter multiple-select multiple-select-dropdown flutter-widget flutter-multiple-selection flutter-multiple-search-selection flutter-multiple-search fuzzy-matching fuzzy-search

multiple_search_selection's Introduction

Version Version

Show some love by dropping a ⭐ at GitHub
HTML tutorial

A highly customizable multiple selection widget with fuzzy search functionality

// Use this controller to adjust the behaviour of the widget
// 1. getAllItems
// 2. getPickedItems
// 3. searchItems
// 4. clearSearchField
// 5. clearAllPickedItems
// 6. selectAllItems
// 7. minCharsToShowItems
// 8. allowDuplicateSelection
// 9. isSelectable
MultipleSearchController controller = MultipleSearchController();
MultipleSearchSelection<Country>(
  // The TextField that is used to search items.
  //
  // You can use this to customize the search field.
  // The `onChanged` of the `searchField` is used internally to search items,
  // so you can use the `onSearchChanged` callback to get the search query.
  searchField: TextField(
    decoration: InputDecoration(
      hintText: 'Search countries',
      border: OutlineInputBorder(
        borderRadius: BorderRadius.circular(6),
        ),
      ),
    ),
  onSearchChanged: (text) {
    print('Text is $text');
  },
  items: countries, // List<Country>
  fieldToCheck: (c) {
    return c.name; // String
  },
  itemBuilder: (country,index,isPicked) {
    return Padding(
      padding: const EdgeInsets.all(6.0),
      child: Container(
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(6),
          color: Colors.white,
        ),
        child: Padding(
          padding: const EdgeInsets.symmetric(
            vertical: 20.0,
            horizontal: 12,
          ),
          child: Text(country.name),
        ),
      ),
    );
  },
  pickedItemBuilder: (country) {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        border: Border.all(color: Colors.grey[400]!),
      ),
      child: Padding(
        padding: const EdgeInsets.all(8),
        child: Text(country.name),
      ),
    );
  },
  onTapShowedItem: () {},
  onPickedChange: (items) {},
  onItemAdded: (item) {},
  onItemRemoved: (item) {},
  sortShowedItems: true,
  sortPickedItems: true,
  fuzzySearch: FuzzySearch.jaro,
  itemsVisibility: ShowedItemsVisibility.alwaysOn,
  title: Text(
    'Countries',
    style: kStyleDefault.copyWith(
      fontSize: 22,
      fontWeight: FontWeight.bold,
    ),
  ),
  showSelectAllButton: true,
  maximumShowItemsHeight: 200,
)

MultipleSearchSelection<T>.creatable

MultipleSearchSelection<T>.creatable constructor can now create new item when search result does not return any results. It takes a new required parameter, createOptions e.g :

// [T] here is [Country]
createOptions: CreateOptions<Country>(
    // You need to create and return the item you want to add since [T] is not always [String].
    create: (text) {
        return Country(name: text, iso: text);
    },
    // A callback when the item is succesfully created.
    onCreated: (c) => print('Country ${c.name} created'),
    // Create item Widget that appears instead of no results.
    createBuilder: (text) => Align(
        alignment: Alignment.centerLeft,
            child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text('Create "$text"'),
            ),
        ),
    // Whether you want to pick the newly created item or just add it to your list. Defaults to false.
    pickCreated: true,
),

Showed items visibility

itemsVisibility behaviour for the default & creatable constructors

ShowedItemsVisibility.alwaysOn ShowedItemsVisibility.onType ShowedItemsVisibility.toggle
Always On On type Toggle

Issues / Features

Found a bug or want a new feature? Open an issue in the Github repository of the project.

multiple_search_selection's People

Contributors

akash-ramaswamy avatar anqit avatar djcharles26 avatar esentis avatar luvti avatar nbxki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

multiple_search_selection's Issues

Select all, Clear all

Hello, thank you for this cool package, really appreciate it

Current Behavior

When selecting all items then clear all. the items doesn't return back to builder list

final MultipleSearchController<GroupModel> ctrl =
      MultipleSearchController<GroupModel>();
      ...
      
  void _select() {
    final List<GroupModel> x = ctrl.getPickedItems();
    final List<String> labels = List.generate(x.length, (i) => x[i].name ?? '');
    widget.onSelect(('$labels').replaceAll(RegExp(r'[\[\]]'), ''), x);
  }
  ...
  
return MultipleSearchSelection<GroupModel>(
 controller: ctrl,
 onItemRemoved: (_) => _select(),
 onItemAdded: (_) => _select(),
 onTapClearAll: () => _select(),
 onTapSelectAll: () => _select(),
 itemBuilder: (GroupModel group, int _) {
        return Container(
          margin: const EdgeInsets.all(6.0),
          padding: const EdgeInsets.fromLTRB(12, 14, 12, 14),
          decoration: Decorations.flat(context),
          child: Text(group.name ?? ''),
        );
      },

Expected behavior/code

When selecting clear all. the items returns back to builder list

SVID_20240618_122211_1-ezgif com-video-to-gif-converter

Full code

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:multiple_search_selection/multiple_search_selection.dart';

import '/app/theme/colors/main_colors.dart';
import '/app/theme/decoration/decorations.dart';
import '/models/ModelProvider.dart';

class CompanyGroupField extends StatefulWidget {
  const CompanyGroupField({
    super.key,
    required this.groups,
    required this.onSelect,
    this.selectedGroups = const <GroupModel>[],
  });
  final List<GroupModel> groups;
  final List<GroupModel> selectedGroups;
  final void Function(String, List<GroupModel>) onSelect;

  @override
  State<CompanyGroupField> createState() => _CompanyGroupFieldState();
}

class _CompanyGroupFieldState extends State<CompanyGroupField> {
  late AppLocalizations arb;

  final MultipleSearchController<GroupModel> ctrl =
      MultipleSearchController<GroupModel>();

  void _select() {
    final List<GroupModel> x = ctrl.getPickedItems();
    final List<String> labels = List.generate(x.length, (i) => x[i].name ?? '');
    widget.onSelect(('$labels').replaceAll(RegExp(r'[\[\]]'), ''), x);
  }

  @override
  void didChangeDependencies() {
    arb = AppLocalizations.of(context)!;
    super.didChangeDependencies();
  }

  @override
  Widget build(BuildContext context) {
    return MultipleSearchSelection<GroupModel>(
      controller: ctrl,
      initialPickedItems: widget.selectedGroups,
      items: widget.groups,
      onItemRemoved: (_) => _select(),
      onItemAdded: (_) => _select(),
      onTapClearAll: () => _select(),
      onTapSelectAll: () => _select(),
      clearSearchFieldOnSelect: true,

      searchField: TextField(
        decoration: InputDecoration(
          hintText: 'Search groups',
          contentPadding: const EdgeInsets.fromLTRB(18, 14, 18, 14),
          focusedBorder: Decorations.formBorderTop(context),
          enabledBorder: Decorations.formBorderTop(context),
          border: Decorations.formBorderTop(context),
        ),
      ),

      pickedItemBuilder: (group) {
        return Container(
          padding: const EdgeInsets.all(8),
          decoration: Decorations.border(context),
          child: Row(
            mainAxisSize: MainAxisSize.min,
            children: [
              Text(group.name ?? ''),
              const SizedBox(width: 4),
              const Icon(Icons.cancel, color: MainColors.red, size: 20),
            ],
          ),
        );
      },

      itemBuilder: (GroupModel group, int _) {
        return Container(
          margin: const EdgeInsets.all(6.0),
          padding: const EdgeInsets.fromLTRB(12, 14, 12, 14),
          decoration: Decorations.flat(context),
          child: Text(group.name ?? ''),
        );
      },

      fieldToCheck: (group) => group.name ?? '',
      noResultsWidget: const SizedBox.shrink(),
      pickedItemsBoxDecoration: Decorations.border(context),
      showedItemsBoxDecoration: Decorations.borderBottom(context),
    );
  }
}

Customize pickedItems display

I think it would be neat to be able to customize certain aspects of the display. In particular, I would like to provide a custom widget to show the picked items.

Failing to work with async data from API

Good day.

Please could you kindly assist. I'm failing to work with data asynchronously fetched from an API for the dropdown. It seems I can only work predefined data.

Not sure if I'm making a mistake or there's a special way I need to access the data.

Regards.

LateInitializationError on controller method

Is your feature request related to a problem?

I'm having a couple of issues with the latest update that removes search field options and instead requires an entire TextField instead. I like the thought of adding more flexibility to the field, however this seems a bit heavy handed to me. To try to get this to work, I've basically had to dig through the older version of the code and copy and paste the text field that was previously being built.
My first issue with this is that now, instead of having to provide just a few options that were of interest to me, I now have to provide the entire TextField. Again, I appreciate the flexibility, but now there is no ability to rely on default options that made things easier to use.
Second, I'm trying to recreate the previously available behavior of being able to clear the search field with showClearSearchFieldButton. It used to be you could just set that to true and everything would work as expected. However, now you have to create the IconButton yourself and use the MultipleSearchSelectionController to clear the search field. But, it turns out that the controller's function isn't set until you initialize the MultipleSearchSelection itself, so this seems like a circular dependency to me. Here's basically what I am trying to do (irrelevant code is deleted):

  final _textController = TextEditingController();
  final _searchController = MultipleSearchController<User>();
// ... other stuff

Widget _selectUsersDropdown() =>
      MultipleSearchSelection<User>(
        controller: _searchController,
// ... other config
        searchField: _searchField(_searchController, _textController),
        hintText: widget.hintText, // slightly confused why this field still exists, shouldn't it just be what's on the search field?
      );

  TextField _searchField(MultipleSearchController<User> searchController, TextEditingController? textEditingController) =>
// this text field is mostly copied from the older version of this library
      TextField(
        enableSuggestions: true,
        autocorrect: true,
        controller: textEditingController,
        decoration: InputDecoration(
          contentPadding: const EdgeInsets.only(
            left: 6,
          ),
          hintText: widget._hintText ?? 'Search for users',
          hintStyle: const TextStyle(
            fontSize: 14,
            fontWeight: FontWeight.bold,
          ),
          border: OutlineInputBorder(
            borderSide: BorderSide.none,
            borderRadius: BorderRadius.circular(20),
          ),
          suffixIcon: IconButton(
            onPressed: searchController.clearSearchField, // **** HERE I try to recreate the clear search field button as before, but this function is not initialized
            icon: const Icon(
              Icons.clear,
            ),
          ),
        ),
      );

I guess the point of this issue is to see if you'd be willing to have it so you can provide the options individually as before, or if you wanted to provide the entire text field, to be able to do that as well, and default to the text field if it is provided, otherwise do the previous behavior. I am also curious to know how to recreate the clear search field button when the controller function has not been initialized.

Thanks!

Can we create a lazy loading (Async) while scrolling

first thanks for such wonderfool component

Is your feature request related to a problem?

A clear and concise description of what the problem is.
Can we do load async data while scrolling the page bcoz in my case i have more than 8k entries to load

Describe the feature you'd like

can we make a async call to database on type

Describe alternatives you've considered

Initial Value still shown in Show select Items

Current Behavior

A clear and concise description of the behavior.

Expected behavior/code

A clear and concise description of what you expected to happen (or code).

Environment

  • Operating System
  • flutter doctor -v

Possible Solution

Only if you have suggestions on a fix for the bug

Additional context/Screenshots

Add any other context about the problem here. If applicable, add screenshots to help explain.

Optionally move pickedItemsContainer to bottom

Customize the position of the pickedItemsContainer

@esentis thanks for this flutter package. I had one usecase where I needed the picked items container to be bottom of the widget stack. So raising this PR for implementation of the specified feature.

Screenshot 2023-11-19 at 10 35 15 AM

Ability to disable predictive text

Firstly, thank you for the terrific widget.

Is your feature request related to a problem?

We use the widget to present a list of the scientific names of plant species entered by users. Users do not want the text to be corrected, as these are not common words.

Describe the feature you'd like

The ability to set autocorrect and enableSuggestions to false for the input text field.

Describe alternatives you've considered

I cannot think of any alternatives.

Stack Overflow post explaining how to disable predictive text

Apologies if the above is possible using the existing widget. I was not able to see how.

How to access the selected value

Current Behavior

This is a wonderful package!! Thanks a lot.
There are two things I am having trouble with

  1. I cant find a method or api to access the selected values
  2. Somewhat related to the first problem!When using creatable it is allowing to add an item that is already selected,

For example: Lets say I added 'Albania' . It would appear as a chip and next time it would not appear in the search and rightly so. However if I create a new item called Albania it would let me add and in the selected item lists two 'Albania' will appear.

Expected behavior/code

a way of accessing the selected values to use it or remove duplicated from the selected ones

Possible Solution

exposing the selected items array or allowing check ifExists in selected list of items would prevent this behavior

showedItems are still displayed when the onType flag is used and clearSearchFieldOnSelect is set to true

Current Behavior

The onType flag is used and clearSearchFieldOnSelect is set to true. After I have added an item to the pickedItems showedItems are visible. It works as intended when I manually empty the searchField.

Expected behavior/code

showedItems aren't visible after adding an item to the pickedItems when the onType flag is used and clearSearchFieldOnSelect is set to true

Possible Solution

Adding something along the lines of
setState(() => expanded = widget.itemsVisibility == ShowedItemsVisibility.onType && widget.searchFieldTextEditingController.text.isNotEmpty);
in the onTap of the GestureDetector in _buildShowedItems().

Error: Type 'OverlayPortalController' not found

Current Behavior

When I install multiple_search_selection version 2.6.2 and assign the first line MultipleSearchController Controller = MultipleSearchController(); and save, detect errors as attached image.

Expected behavior/code

A clear and concise description of what you expected to happen (or code).

Environment

  • Operating System
  • flutter doctor -v

[√] Flutter (Channel stable, 3.7.3, on Microsoft Windows [Version 10.0.19045.3930], locale en-US)
• Flutter version 3.7.3 on channel stable at C:\src\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 9944297138 (1 year, 1 month ago), 2023-02-08 15:46:04 -0800
• Engine revision 248290d6d5
• Dart version 2.19.2
• DevTools version 2.20.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at C:\Users\tailn\AppData\Local\Android\sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[!] Visual Studio - develop for Windows (Visual Studio Community 2022 17.8.0)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.8.34309.116
X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop
development with C++" workload, and include these components:
MSVC v142 - VS 2019 C++ x64/x86 build tools
- If there are multiple build tool versions available, install the latest
C++ CMake tools for Windows
Windows 10 SDK

[√] Android Studio (version 2022.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)

[√] VS Code (version 1.83.1)
• VS Code at C:\Users\tailn\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.82.0

[√] Connected device (4 available)
• sdk gphone x86 64 (mobile) • emulator-5554 • android-x64 • Android 13 (API 33) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.3930]
• Chrome (web) • chrome • web-javascript • Google Chrome 121.0.6167.86
• Edge (web) • edge • web-javascript • Microsoft Edge 122.0.2365.59

[√] HTTP Host Availability
• All required HTTP hosts are available

Possible Solution

Only if you have suggestions on a fix for the bug

Additional context/Screenshots

Screenshot 2024-03-01 161213

Add any other context about the problem here. If applicable, add screenshots to help explain.

Inconsistent parameter naming for focus nodes in constructors

Current Behavior

in creatable factory it is searchFieldFocus but in default const it is still textFieldFocus

Expected behavior/code

should be consistent

Environment

  • Operating System
  • flutter doctor -v

Possible Solution

Only if you have suggestions on a fix for the bug

Additional context/Screenshots

Add any other context about the problem here. If applicable, add screenshots to help explain.

Hide items until a certain number of characters are entered into search

Describe the feature you'd like

Firstly thank you for the excellent widget, we use it throughout our app.

Our use case is to add a user to a project. There is a list of all users who have signed up to the app that they can select from, however from a privacy perspective we do not want the user to be able to see all users. The list of users should be hidden and only show up when the user has entered a number of characters into the search field (lets say 3). It feels like there should be a simple way to add this functionality, for example with a new itemVisibility option (for example ShowedItemsVisibility.onEntered(3)).

Describe alternatives you've considered

I have tried working with onSearchChanged using the new multipleSearchController, and considered editing the text entered into SearchField, but I feel like I am fighting with the existing code and can't seem to find a simple solution. Perhaps I am overlooking something?

Thanks again!

Disable Creatable

Is your feature request related to a problem?

Our use case is that we would like to allow existing users to invite other users to install our app. They would enter the new users' email address into the widget using the creatable constructor.

Describe the feature you'd like

We would like to disable the ability of the user to tap on the 'createBuilder' text (and create a new user) until a valid email address is entered. Our createBuilder is something like below:

                                                createBuilder: (text) {
                                                  if (EmailValidator.validate(
                                                      text)) {
                                                    return Align(
                                                      alignment:
                                                          Alignment.centerLeft,
                                                      child: Padding(
                                                        padding:
                                                            const EdgeInsets
                                                                .all(8.0),
                                                        child: Text(
                                                            'Invite $text'),
                                                      ),
                                                    );
                                                  } else {
                                                    return const Align(
                                                          alignment: Alignment
                                                              .centerLeft,
                                                          child: Padding(
                                                            padding:
                                                                EdgeInsets.all(
                                                                    8.0),
                                                            child: Text(
                                                                'Invalid email address'),
                                                          ),
                                                        );
                                                  }
                                                },

When the email address is invalid they should not be able to tap on the createBuilder. I imagine enabling/disabling the onTap for the createBuilder would be useful in other circumstances as well.

Describe alternatives you've considered

I have tried disabling with GestureDetector and AbsorbPointer.

Thanks for the great widget!

Error: No named parameter with the name 'thumbVisibility'.

Current Behavior

cannot run debug or build on android

Expected behavior/code

i tried to implement MultipleSearchSelection , and the dart formatter looks like having no issue
this is the code

Container(
    margin: EdgeInsets.symmetric(vertical: 10),
    child: MultipleSearchSelection<TeamsData>(
      onTapShowedItem: () => Loggers.warning('onTapShowedItem'),
      items: _teamsData!,
      fieldToCheck: (c) {
        return c.username;
      },
      itemBuilder: (data) {
        return Padding(
          padding: const EdgeInsets.all(6.0),
          child: Container(
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(6),
              color: Colors.white,
            ),
            child: Padding(
              padding: const EdgeInsets.symmetric(
                vertical: 20.0,
                horizontal: 12,
              ),
              child: Text(data.username),
            ),
          ),
        );
      },
      pickedItemBuilder: (country) {
        return Container(
          decoration: BoxDecoration(
            color: Colors.white,
            border: Border.all(color: Colors.grey[400]!),
          ),
          child: Padding(
            padding: const EdgeInsets.all(8),
            child: Text(country.username),
          ),
        );
      },
      onPickedChange: (items) {
        print(items);
      },
    ),
  ),

Environment

  • Operating System Windows 11
  • flutter doctor -v result
[√] Flutter (Channel stable, 2.10.5, on Microsoft Windows [Version 10.0.22000.795], locale en-ID)
    • Flutter version 2.10.5 at C:\Users\galih\Projects\google\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5464c5bac7 (4 months ago), 2022-04-18 09:55:37 -0700
    • Engine revision 57d3bac3dd
    • Dart version 2.16.2
    • DevTools version 2.9.2
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.69.2)
    • VS Code at C:\Users\galih\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.44.0

[√] Connected device (4 available)
    • sdk gphone x86 arm (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)           • windows       • windows-x64    • Microsoft Windows [Version 10.0.22000.795]
    • Chrome (web)                • chrome        • web-javascript • Google Chrome 103.0.5060.134
    • Edge (web)                  • edge          • web-javascript • Microsoft Edge 102.0.1245.39

[√] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Error Log

> Task :app:compileFlutterBuildDebug
../../google/flutter/.pub-cache/hosted/pub.dartlang.org/multiple_search_selection-2.1.0/lib/multiple_search_selection.dart:426:17: Error: No named parameter with the name 'thumbVisibility'.
                thumbVisibility: widget.showPickedItemScrollbar,
                ^^^^^^^^^^^^^^^
../../google/flutter/packages/flutter/lib/src/widgets/scrollbar.dart:865:9: Context: Found this candidate, but the arguments don't match.
  const RawScrollbar({
        ^^^^^^^^^^^^
../../google/flutter/.pub-cache/hosted/pub.dartlang.org/multiple_search_selection-2.1.0/lib/multiple_search_selection.dart:638:43: Error: No named parameter with the name 'thumbVisibility'.
                                          thumbVisibility:
                                          ^^^^^^^^^^^^^^^
../../google/flutter/packages/flutter/lib/src/widgets/scrollbar.dart:865:9: Context: Found this candidate, but the arguments don't match.
  const RawScrollbar({
        ^^^^^^^^^^^^
../../google/flutter/.pub-cache/hosted/pub.dartlang.org/multiple_search_selection-2.1.0/lib/multiple_search_selection.dart:911:17: Error: No named parameter with the name 'thumbVisibility'.
                thumbVisibility: widget.showShowedItemsScrollbar,
                ^^^^^^^^^^^^^^^
../../google/flutter/packages/flutter/lib/src/widgets/scrollbar.dart:865:9: Context: Found this candidate, but the arguments don't match.
  const RawScrollbar({
        ^^^^^^^^^^^^


> Task :app:compileFlutterBuildDebug FAILED                                                                                                                                         

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\galih\Projects\google\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1102

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.                                                                                                                          
> Process 'command 'C:\Users\galih\Projects\google\flutter\bin\flutter.bat'' finished with non-zero exit value 1                                                                    

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 25s
1 actionable task: 1 executed

Case sensitivity in search is broken

Want to start by saying this is a great widget, it was the only one I could find that met all of my criteria, thanks!

Current Behavior

When searching using capital letters, items who fieldToCheck contains that capital letter are not returned.

For example, if I was searching for some User object that had a name field and fieldToCheck was (u) => u.name, I had a user whose name value was Anqit, and I searched for A, Anqit is not returned, however if I search for a, it is.

I believe it is because of lines like (item) => widget.fieldToCheck(item).toLowerCase().contains(_textEditingController.text). Here, the value returned from fieldToCheck is converted to lower case, but the text value from the controller is not.

Expected behavior/code

I would expect searching using capital letters should return items whose fieldToCheck values contains those capital letters.

Environment

Don't think this is relevant

Possible Solution

A quick fix would be to also convert the text field value to lower-case in all of the places the search is done:
(item) => widget.fieldToCheck(item).toLowerCase().contains(_textEditingController.text.toLowerCase())
A cool feature might be being able to provide a custom search function, maybe something that takes the text field value and returns a custom list of items. Or perhaps have the case sensitivity configurable (and working ;) )

The dropdown is pushing other widgets down

Current Behavior

Currently when the dropdown expands it pushes the other widgets down which are next to it. Not too sure if this is by design or a setting exists that could turn it to a overlay.

Generally the standard material or cupertino dropdown overlays the dropdown over the widget
This behavior makes the user experience "jarry"

Expected behavior/code

Generally the standard material or cupertino dropdown overlays the dropdown over the widget

Environment

  • Operating System
  • flutter doctor -v

Possible Solution

Implement or expose a setting for overlay if it already exists

Additional context/Screenshots

Add any other context about the problem here. If applicable, add screenshots to help explain.

The focus is messed up if there are multiple search selection widgets or textfields in a page

Current Behavior

create more than one multiple search selection widgets in a page
Noticed following behaviours

  1. The keyboard disappears if you focus on search selection
  2. If you focus on some other textfield and then click search selection it is likely to work
  3. Sometimes the focus keep jumping from one search selection to other

Mostly the behaviour is inconsistent
I have tried with same or different focus nodes . Nothing seems to work. I am no expert in focus nodes though :)

My current set up that is relatively stable

I have a page with 1 textfield and two search selections
I have added separate global keys to both search selections

If I open the page and immediately focus on search selection the keyboard disappears
however if I focus on the textfield and then focus on the search selection it seems to work

I may be missing something basic.

Expected behavior/code

Environment

  • Operating System
  • flutter doctor -v

Possible Solution

Only if you have suggestions on a fix for the bug

Additional context/Screenshots

Add any other context about the problem here. If applicable, add screenshots to help explain.

Ability to specify TextInputType

Current Behavior

As this is essentially a text input type , there should be an option to specify text input type. Looks like the current behavior default to TextInputType to text and there is no way to change it

Expected behavior/code

Ability to specify textinputtype such as name, email etc

Environment

  • Operating System
  • flutter doctor -v

Possible Solution

Only if you have suggestions on a fix for the bug

Additional context/Screenshots

Add any other context about the problem here. If applicable, add screenshots to help explain.

Object selection options

Describe the feature you'd like

  1. Is it possible to select custom objects other than String in the dropdown? Often choices will have an ID for form processing and a String for display:

items: MyObj (id: ..., name: ..., toString() => name)

  1. Support for async data fetch for populating items instead of expecting all items available up front. Even better if the data fetch is paginated.

Add dynamic array

Is your feature request related to a problem?

A clear and concise description of what the problem is.
I have an issue when [...]

Describe the feature you'd like

A clear and concise description of what you want to happen. Add any considered drawbacks.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

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.