This Flutter package provides a Search Widget for selecting an option from a data list

Overview

Search Widget Cirrus CI - Base Branch Build Status GitHub stars Twitter Follow GitHub last commit Website shields.io Open Source Love style: effective dart

This Flutter package provides a Search Widget for selecting an option from a data list. Provides filtering of items based on the search text.

PieChart

💻 Installation

In the dependencies: section of your pubspec.yaml, add the following line:

Version

dependencies:
  search_widget: 
   

Usage

Import this class

import 'package:search_widget/search_widget.dart';

Add Search Widget

  • Accepts data list as input
  • Option for getting selected item. Returns selected item or null if item is deleted
onItemSelected: (item) {
    //Do whatever you would like
    setState(() {
       _selectedItem = item;
    });
 },
  • Option for pop list item builder. This basically returns a widget to show as list item in popup
popupListItemBuilder: (LeaderBoard item) {
   return PopupListItem(item);
 }
  • Option for filtering data list based on search query
queryBuilder: (String query, List<LeaderBoard> list) {
   return list.where((LeaderBoard item) => item.username.toLowerCase().contains(query.toLowerCase())).toList();
 }
  • Option provided for selected list item builder which enables when a user selects an item from pop up list
selectedItemBuilder: (LeaderBoard selectedItem, deleteSelectedItem) {
   return SelectedItem(selectedItem,deleteSelectedItem);
 }
  • Option for providing custom TextField. Accepts TextEditingController and FocusNode as parameter
textFieldBuilder: (TextEditingController controller, FocusNode focusNode) {
    return TextField(
        controller: controller,
        focusNode: focusNode,
        //... Other customizations here
       );
  },

Full Implementation

SearchWidget<LeaderBoard>(
   dataList: list,
   hideSearchBoxWhenItemSelected: false,
   listContainerHeight: MediaQuery.of(context).size.height / 4,
   queryBuilder: (String query, List<LeaderBoard> list) {
     return list.where((LeaderBoard item) => item.username.toLowerCase().contains(query.toLowerCase())).toList();
   },
   popupListItemBuilder: (LeaderBoard item) {
     return PopupListItemWidget(item);
   },
   selectedItemBuilder: (LeaderBoard selectedItem, VoidCallback deleteSelectedItem) {
     return SelectedItemWidget(selectedItem, deleteSelectedItem);
   },
   // widget customization
   noItemsFoundWidget: NoItemsFound(),
   textFieldBuilder: (TextEditingController controller, FocusNode focusNode) {
     return MyTextField(controller, focusNode);
   },
 )

Key Highlights

  • Adaptive Popup Position to prevent popup getting hidden behind keyboard

PieChart PieChart

  • Popup to scroll with scroll gesture if this widget is used inside ScrollView

PieChart

TODO

  • Give support for onItemSelected method to return selected item(s) directly
  • Add support for selecting multiple items
  • Add visibility bool to show selected item widget

My Flutter Packages

  • pie_chart GitHub stars Flutter Pie Chart with cool animation.
  • avatar_glow GitHub stars Flutter Avatar Glow Widget with glowing animation.
  • json_table GitHub stars Create Flutter Json Table from json map directly.
  • animating_location_pin GitHub stars Flutter Animating Location Pin Widget providing Animating Location Pin Widget which can be used while fetching device location.

My Flutter Apps

👍 Contribution

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -m 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Comments
  • [web] Positioning issue with overlay

    [web] Positioning issue with overlay

    I'm new to Flutter and so wasn't able to figure out quite what's going wrong, but I can't get SearchWidget to work on web. The Inkwell gets highlighted when my cursor is at some offset from the actual list item, and clicking when the inkwell is highlighted just closes the overlay. Clicking on the actual list item doesn't work either. In both cases the overlay just gets closed.

    I suspect it has something to do with the Positioned or CompositedTransformFollower widgets. This gist has a trivial example Flutter web app that demonstrates the issue.

    Would love to get this working, other than this issue it seems to be a really nice widget. Let me know how I can help debug.

    opened by rofrankel 9
  • Exception caught by services library: MissingPluginException

    Exception caught by services library: MissingPluginException

    Hi, it works in the app but I get this exception. Running on newest version 1.0.1, though same error when trying with 1.0.0.

    I/flutter ( 8648): ══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY 
    I/flutter ( 8648): The following MissingPluginException was thrown while activating platform stream on channel
    I/flutter ( 8648): flutter_keyboard_visibility:
    I/flutter ( 8648): MissingPluginException(No implementation found for method listen on channel
    I/flutter ( 8648): flutter_keyboard_visibility)
    
    [√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Version 10.0.17763.914], locale en-US)
    
    [√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    [√] Android Studio (version 3.5)
    [√] VS Code (version 1.35.0)
    [√] Connected device (1 available)
    
    • No issues found!
    
    opened by anthonyym 9
  • The method 'markNeedsBuild' was called on null.

    The method 'markNeedsBuild' was called on null.

    The method 'markNeedsBuild' was called on null. Receiver: null Tried calling: markNeedsBuild() >>>> TRACE <<<< #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:50:5) #1 MySingleChoiceSearchState.init.<anonymous closure> (package:search_widget/search_widget.dart:109:22) #2 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:206:21) #3 ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:273:5) #4 TextEditingController.clear (package:flutter/src/widgets/editable_text.dart:183:5) #5 MySingleChoiceSearchState.onDropDownItemTap (package:search_widget/search_widget.dart:193:17) #6 MySingleChoiceSearchState.onTap.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:search_widget/search_widget.dart:257:39) #7 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:635:14) #8 _InkResponseState.build.<anonymous closure> (package:flu<…>

    opened by tula-Intelads 4
  • Select value in textfield

    Select value in textfield

    Goodmorning again,

    Went through your packages and this is exactly what i need. The only thing i would like to have different is that whenever you choose an item, it is selected in the textField and not in a card below the searchfield. I tried to sent the controller to the selectedItemBuilder and set the text from there, but that didn't seem to work.

    Is there any way on doing this?

    opened by SJente 4
  • Remove overlay on dispose

    Remove overlay on dispose

    I have an icon that opens and closes the SearchWidget. It works great unless I close it without selecting a result. The search results list remains in the overlay even after the SearchWidget is disposed if no item was selected from within the results.

    opened by glorpy 2
  • The method 'toLowerCase' was called on null.

    The method 'toLowerCase' was called on null.

    In the queryBulider function this keeps out putting "The method 'toLowerCase' was called on null." and the query has value.

    queryBuilder: (String query, List<Word> list) {
                               return list.where(
                                    (Word item) => item.translation.toLowerCase().contains(query.toLowerCase())
                               ).toList();
                          },
    

    my Word data structure is

    class Word{
      int id,difficulty;
      String word,definition1,definition2,example,translation;
    
      Word({this.id,this.word,this.definition1,this.definition2,this.difficulty,this.example,this.translation});
    }
    

    Really appreciate what you did tho.

    opened by JosephVoid 1
  • Showing Error in Both iOS and Android

    Showing Error in Both iOS and Android

    It's returning error like this in both Android and iOS

    / . ***/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java:6: error: a type with the same simple name is already defined by the single-type-import of KeyboardVisibilityPlugin import com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin; ^ 1 error

    FAILURE: Build failed with an exception.

    • What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.

    Compilation failed; see the compiler error output for details.

    • 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 . .\

    opened by balajiks-dev 1
  • After I updated the flutter v1.13.2 He is returning this error to me.

    After I updated the flutter v1.13.2 He is returning this error to me.

    C:\Users\Mobile02\AndroidStudioProjects\siga_atividade_coletiva\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java:5: error: a type with the same simple name is already defined by the single-type-import of KeyboardVisibilityPlugin import com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin; ^ 1 error

    FAILURE: Build failed with an exception.

    • What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.

    Compilation failed; see the compiler error output for details.

    • 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

    BUILD FAILED in 3m 40s Finished with error: Gradle task assembleDebug failed with exit code 1

    opened by emilson-silva 1
  • Android emulator doesn't work

    Android emulator doesn't work

    when I add this widget as dependency to my Pubspec.yaml file, the app will crash when I run it in debug mode on an android emulator and it gives me this error:

    error: a type with the same simple name is already defined by the single-type-import of KeyboardVisibilityPlugin import com.github.adee42.keyboardvisibility.KeyboardVisibilityPlugin; ^ 1 error

    FAILURE: Build failed with an exception.

    • What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.

    Compilation failed; see the compiler error output for details.

    • 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

    the version for the widget is search_widget: ^0.2.0 the app works without it

    opened by mohammadreza490 1
  • Added lots of customizations

    Added lots of customizations

    I've added a couple new parameters to SearchWidget, as well as NoItemFound:

    • Now you can customize & reuse the NoItemFound widget. You can change its title & icon.
    • Ability to select custom padding & contentPadding for the text box.
    • Ability to change both enabled & focused borders.
    • Customize prefix & suffix icons in the text box.
    • Custom text style.
    • Show custom widget when unsuccessful search.
    • Updated example project to reflect these changes.
    • Done quite a bunch of refactor.
    • Updated .gitignore file.

    If there's anything wrong, please contact me. You can update or change whatever you want :)

    opened by jesusrp98 1
  • [ImgBot] Optimize images

    [ImgBot] Optimize images

    Beep boop. Your images are optimized!

    Your image file size has been reduced by 31% 🎉

    Details

    | File | Before | After | Percent reduction | |:--|:--|:--|:--| | /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png | 14.45kb | 9.69kb | 32.93% | | /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png | 45.89kb | 31.58kb | 31.18% | | /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png | 1.40kb | 1.00kb | 28.62% | | /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png | 5.79kb | 4.27kb | 26.23% | | /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png | 3.20kb | 2.60kb | 18.77% | | | | | | | Total : | 70.73kb | 49.15kb | 30.52% |


    📝docs | :octocat: repo | 🙋issues | 🏅swag | 🏪marketplace

    opened by imgbot[bot] 0
  • Migrate to null safety & fix deprecated warnings

    Migrate to null safety & fix deprecated warnings

    Fixes #30 #29 #22

    • Upgrades flutter_keyboard_visibility to fix deprecation warning
    • Upgrades dart version and migrated to use null safety
    • Updates example app so that it works with new changes
    opened by Villarrealized 0
  • Depricated API used

    Depricated API used

    Hello, seems you using a deprecated API with name " flutter_keyboard_visibility-0.7" ...although the app works fine ..the error keeps coming .

    opened by beautybird 3
  • close indication

    close indication

    hi there,

    is there any indication for search close without selection (such as back press event or outside click)?

    what i'm trying to do is to implement a functionality where there is dim screen behind the results list only when its open.

    opened by man-person 1
Owner
Ayush P Gupta
Flutter || Node || Vue || Typescript
Ayush P Gupta
Picture upload widget for Flutter which helps selecting and uploading one or multiple images to firebase storage.

Flutter Firebase Picture Uploader This library offers a Picture Upload widget which can be used to upload one or multiple images to your Firebase Stor

Christoph Rothermel 12 Oct 21, 2022
Widget for selecting between ThemeMode.dark and ThemeMode.light

ThemeModeSelector Widget I am currently working with the concept of Theme's in Flutter and I wanted to build a widget which would allow me to switch b

null 10 Oct 26, 2022
Ali Türkay AVCI 1 Jan 20, 2022
Flutter plugin for selecting images from the Android and iOS image library, taking new pictures with the camera, and edit them before using such as rotation, cropping, adding sticker/text/filters.

advance_image_picker Flutter plugin for selecting multiple images from the Android and iOS image library, taking new pictures with the camera, and edi

Weta Vietnam 91 Dec 19, 2022
My-First-Flutter-App - Startup Name Generator App with favorites option

Startup Name Generator App with 'favorites' option.. This is my first Flutter ap

REDLUNA CRYSTAL 0 Jan 21, 2022
User auth form - Signup and signin user auth form with ability to stay signed in and have an option to signout.

user_auth_form SIgnup and signin user authentification form Getting Started This project is a starting point for a Flutter application. A few resource

null 0 Jan 6, 2022
Ruqe brings the convenient types and methods found in Rust into Dart, such as the Result, Option, pattern-matching, etc.

ruqe Ruqe brings the convenient types and methods found in Rust into Dart, such as the Result, Option, pattern-matching, etc. Additionally, the librar

Alexander Nitiola 12 Dec 28, 2022
Github-search - Allows users to search users on github Uses flutter

Github Search Github Search is a cross-platform mobile application powered by Flutter Framework and Github API. The application was built with simplic

Saul 3 Sep 13, 2022
A google browser clone which is made by using flutter and fetching the google search api for the search requests.

google_clone A new Flutter project. Project Preview Getting Started This project is a starting point for a Flutter application. A few resources to get

Priyam Soni 2 May 31, 2022
Starlight search bar - Starlight search bar with flutter

starlight_search_bar If you find the easiest way to search your item, this is fo

Ye Myo Aung 1 Apr 20, 2022
Data Migrator - provide a universal translator for data by being portable, diverse, and efficient in migrating and converting data across discrete schemas

Data Migrator - provide a universal translator for data by being portable, diverse, and efficient in migrating and converting data across discrete schemas

Tanner Meade 77 Jan 2, 2023
Horizontal list - A horizontal list widget to use in mainly for web or desktop application

horizontal_list A horizontal list widget with buttons next and previous. You can

Daniel 2 Feb 2, 2022
This is my way to build a Tagged Search Field that display a list with suggestions while the user type.

tagged_search_field This is my way to build a Tagged Search Field that display a list with suggestions while the user type. A regular search field at

Sherly Cabrera Sánchez 0 Nov 5, 2021
Dart package for Async Data Loading and Caching. Combine local (DB, cache) and network data simply and safely.

Stock is a dart package for loading data from both remote and local sources. It is inspired by the Store Kotlin library.

xmartlabs 59 Dec 24, 2022
A Flutter package that provides an Emoji Keyboard widget.

Flutter Choose Keyboard A Flutter package that provides an Emoji Keyboard widget. BASED IN: https://github.com/JeffG05/emoji_picker Key Features Flutt

null 1 Oct 22, 2021
A flutter UI package provides a cell widget that has leading and trailing swipe action menu.

Language: English |中文简体 flutter_swipe_action_cell A package that can give you a cell that can be swiped ,effect is like iOS native If you like this pa

WenJingRui 261 Jan 7, 2023
A package that provides a highly customizable sheet widget that snaps to different vertical & horizontal positions

Snapping Sheet A package that provides a highly customizable sheet widget that snaps to different vertical & horizontal positions Can adapt to scrolla

Adam Jonsson 364 Dec 6, 2022
A simple application that provides data from github friends, among them their commits.

A simple application that provides data from github friends, among them their commits.

Matheus Ferreira 0 May 18, 2022
MindInventory 15 Sep 5, 2022