GithubHelp home page GithubHelp logo

abouassi98 / multiple_search_selection Goto Github PK

View Code? Open in Web Editor NEW

This project forked from esentis/multiple_search_selection

1.0 0.0 0.0 3.01 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

Objective-C 0.06% Kotlin 0.19% Dart 93.28% Swift 0.60% HTML 5.88%

multiple_search_selection's Introduction

Version Version

A highly customizable multiple selection widget with fuzzy search functionality

MultipleSearchSelection<Country>(
        items: countries, // List<Country>
        fieldToCheck: (c) {
          return c.name; // String
        },
        itemBuilder: (country) {
          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,
        searchItemTextContentPadding:
            const EdgeInsets.symmetric(horizontal: 10),
        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].
    createItem: (text) {
        return Country(name: text, iso: text);
    },
    // A callback when the item is succesfully created.
    onItemCreated: (c) => print('Country ${c.name} created'),
    // Create item Widget that appears instead of no results.
    createItemBuilder: (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.
    pickCreatedItem: true,
),

Showed items behavior

Always on On type 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

esentis avatar anqit avatar abouassi98 avatar djcharles26 avatar luvti avatar

Stargazers

 avatar

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.