New Self New Life
No Result
View All Result
  • Home
  • Entertainment
  • Celebrity
  • Cinema
  • Music
  • Digital Lifestyle
  • Social Media
  • Softwares
  • Devices
  • Home
  • Entertainment
  • Celebrity
  • Cinema
  • Music
  • Digital Lifestyle
  • Social Media
  • Softwares
  • Devices
New Self New Life
No Result
View All Result
Home Softwares

Multiple Search Selection In Flutter

by admin
2 years ago
in Softwares
Multiple Search Selection In Flutter
Share on FacebookShare on Twitter


On this weblog, we’ll discover the right way to Implement A number of Search Choice In Flutter.

Flutter is a versatile and highly effective framework for constructing cross-platform cellular purposes.

customers to seek for objects and choose a number of choices, making it helpful for varied eventualities like choosing tags, classes, or filtering information.

You may additionally verify our flutter app growth firm web page.

Implementation:-

First we have to create a brand new flutter undertaking and add the next dependencies within the pubspec.yaml file.

dependencies:
flutter:
sdk: flutter
multiple_search_selection: ^2.5.3

Now, run the command “flutter pub get” so as to add the dependencies.

Add the next package deal to your class.

import ‘package deal:multiple_search_selection/multiple_search_selection.dart’;

We are going to first create MultipleSearchSelection:

We create a Stateful Widget A number of Search Choice that holds the state of our widget.

MultipleSearchSelection<T>.creatable(
            title: title;
            createOptions: CreateOptions(
              createItem: (textual content) {
                return Metropolis(title: textual content,);
              },
              createItemBuilder: (textual content) => Align(
                alignment: Alignment.centerLeft,
                little one: Padding(
                  padding: const EdgeInsets.all(8.0),
                  little one: Textual content('Create "$textual content"'),
                ),
              ),
            ),
            objects: objects,
            fieldToCheck: (c) {
              return c.title;
            },
            itemBuilder: (nation, index) {
              return merchandise listing view;
            },
            pickedItemBuilder: (nation) {
              return chosen merchandise view;
            },        
          ),

Let’s essential elements of this code:

  1. MultipleSearchSelection<T>:
    This the customized widget’s title, and it takes a sort parameter T to specify the kind of objects it really works with.
  2. title:
    It seems to be a title for the search and choice part.
  3. createOptions:
    It is a configuration for creating new objects inside the search choice part. It consists of:
    • createItem:
      A operate that takes textual content as enter and seems to create a brand new merchandise (e.g., a Metropolis with the given title).
    • createItemBuilder:
      A operate that returns a widget for displaying the newly created merchandise.
  4. objects:
    It appears to be the listing of things that the consumer can search by and choose from.
  5. fieldToCheck:
    It is a operate that checks a property of every merchandise to match towards the search enter.
  6. itemBuilder:
    A operate that takes an merchandise and an index and may return a widget to show every merchandise within the listing.
  7. pickedItemBuilder:
    A operate that takes a picked merchandise and may return a widget to show the chosen merchandise.

full code:-

import 'package deal:flutter/materials.dart';
import 'package deal:multiple_search_selection/helpers/create_options.dart';
import 'package deal:multiple_search_selection/multiple_search_selection.dart';

class SearchScreen extends StatefulWidget {
  const SearchScreen({
    Key? key,
  }) : tremendous(key: key);

  @override
  State<SearchScreen> createState() => _SearchScreenState();
}

class _SearchScreenState extends State<SearchScreen> {
  Listing<Metropolis> cities = [];

  @override
  void initState() {
    cities = [
      City(name: 'Mumbai'),
      City(name: 'Delhi'),
      City(name: 'Bangalore'),
      City(name: 'Chennai'),
      City(name: 'Kolkata'),
      City(name: 'Hyderabad'),
      City(name: 'Ahmedabad'),
      City(name: 'Jaipur'),
      City(name: 'Lucknow'),
      City(name: 'Surat'),
      City(name: 'Kanpur'),
      City(name: 'Nagpur'),
      City(name: 'Patna'),
      City(name: 'Indore'),
      City(name: 'Thane'),
      City(name: 'Bhopal'),
      City(name: 'Visakhapatnam'),
      City(name: 'Vadodara'),
      City(name: 'Miami'),
      City(name: 'New York'),
      City(name: 'Los Angeles'),
      City(name: 'Chicago'),
      City(name: 'San Francisco'),
      City(name: 'Miami'),
      City(name: 'Philadelphia'),
      City(name: 'San Antonio'),
      City(name: 'San Diego'),
      City(name: 'Dallas'),
      City(name: 'San Jose'),
      City(name: 'Austin'),
      City(name: 'Jacksonville'),
      City(name: 'Indianapolis'),
      City(name: 'Columbus'),
      City(name: 'Fort Worth'),
      City(name: 'Charlotte'),
      City(name: 'Seattle'),
      City(name: 'Denver'),
      City(name: 'Washington, D.C.'),
      City(name: 'Boston'),
      City(name: 'El Paso'),
      City(name: 'Nashville'),
      City(name: 'Oklahoma City'),
      City(name: 'Pune'),
      City(name: 'Kathmandu'),
      City(name: 'Pokhara'),
      City(name: 'Lalitpur'),
      City(name: 'Bhaktapur'),
      City(name: 'Biratnagar'),
      City(name: 'Butwal'),
      City(name: 'Nepalgunj'),
      City(name: 'Dharan'),
      City(name: 'Hetauda'),
      City(name: 'Birgunj'),
      City(name: 'Janakpur'),
      City(name: 'Dhangadhi'),
      City(name: 'Bharatpur'),
      City(name: 'Siddharthanagar'),
      City(name: 'Ghorahi'),
      City(name: 'Dhankuta'),
      City(name: 'Ilam'),
      City(name: 'Birendranagar'),
      City(name: 'Tansen'),
      City(name: 'Rajbiraj'),
    ];
    tremendous.initState();
  }

  @override
  Widget construct(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      dwelling: Scaffold(
        appBar: AppBar(
          title: const Textual content("A number of Search Choice"),
        ),
        physique: SingleChildScrollView(
          little one: MultipleSearchSelection<Metropolis>.creatable(
            title: Padding(
              padding: const EdgeInsets.all(12.0),
              little one: Textual content(
                'Metropolis',
                type: Theme.of(context).textTheme.bodyMedium?.copyWith(
                      fontSize: 22,
                      fontWeight: FontWeight.daring,
                    ),
              ),
            ),
            showClearSearchFieldButton: true,
            createOptions: CreateOptions(
              createItem: (textual content) {
                return Metropolis(
                  title: textual content,
                );
              },
              createItemBuilder: (textual content) => Align(
                alignment: Alignment.centerLeft,
                little one: Padding(
                  padding: const EdgeInsets.all(8.0),
                  little one: Textual content('Create "$textual content"'),
                ),
              ),
              pickCreatedItem: true,
            ),
            objects: cities,
            fieldToCheck: (c) {
              return c.title;
            },
            itemBuilder: (nation, index) {
              return Padding(
                padding: const EdgeInsets.all(6.0),
                little one: Container(
                  ornament: BoxDecoration(
                    borderRadius: BorderRadius.round(6),
                    coloration: Colours.white,
                  ),
                  little one: Padding(
                    padding: const EdgeInsets.symmetric(
                      vertical: 20.0,
                      horizontal: 12,
                    ),
                    little one: Textual content(nation.title),
                  ),
                ),
              );
            },
            pickedItemBuilder: (nation) {
              return Container(
                ornament: BoxDecoration(
                    coloration: Colours.white,
                    border: Border.all(coloration: Colours.gray[400]!),
                    borderRadius: BorderRadius.round(4)),
                little one: Padding(
                  padding: const EdgeInsets.all(8),
                  little one: Textual content(nation.title),
                ),
              );
            },
            selectAllButton: Padding(
              padding: const EdgeInsets.all(12.0),
              little one: DecoratedBox(
                ornament: BoxDecoration(
                    border: Border.all(coloration: Colours.gray),
                    borderRadius: BorderRadius.round(4)),
                little one: Padding(
                  padding: const EdgeInsets.all(8.0),
                  little one: Textual content(
                    'Choose All',
                    type: Theme.of(context).textTheme.bodyMedium,
                  ),
                ),
              ),
            ),
            clearAllButton: Padding(
              padding: const EdgeInsets.all(12.0),
              little one: DecoratedBox(
                ornament: BoxDecoration(
                    border: Border.all(coloration: Colours.gray),
                    borderRadius: BorderRadius.round(4)),
                little one: Padding(
                  padding: const EdgeInsets.all(8.0),
                  little one: Textual content(
                    'Clear All',
                    type: Theme.of(context).textTheme.bodyMedium,
                  ),
                ),
              ),
            ),
            caseSensitiveSearch: false,
            fuzzySearch: FuzzySearch.none,
            itemsVisibility: ShowedItemsVisibility.alwaysOn,
            showSelectAllButton: true,
            maximumShowItemsHeight: 525,
          ),
        ),
      ),
    );
  }
}

class Metropolis {
  remaining String title;

  Metropolis({required this.title});
}

Output:-

Conclusion:-

We’ve accomplished with implementation of A number of Search Choice In Flutter.

Test right here for extra fascinating blogs – https://mobikul.com/weblog/

Hope this weblog helped you to raised perceive the implementation of A number of Search Choice In Flutter.

Thanks for studying this weblog ❤️

References:-

https://pub.dev/packages/multiple_search_selection

author-thumb

Sakshi Rai
4 Badges

10 October 2023



Source link

Tags: FlutterMultiplesearchSelection
Previous Post

The Best Navy Blazer Brands & Tailors For Men: 2023 Addition

Next Post

Reducing the Cloud Carbon Footprint of bol. | Blog | bol.com

Related Posts

Verification framework uncovers safety lapses in open-source self-driving system
Softwares

Verification framework uncovers safety lapses in open-source self-driving system

by admin
May 23, 2025
PrestaShop Free Gift Products | Add Free Products to Cart
Softwares

PrestaShop Free Gift Products | Add Free Products to Cart

by admin
May 22, 2025
The emperors of AI coding tools have no clothes – and it’s creating a productivity delusion
Softwares

The emperors of AI coding tools have no clothes – and it’s creating a productivity delusion

by admin
May 20, 2025
Land Your First Programming Job in 7 Steps
Softwares

Land Your First Programming Job in 7 Steps

by admin
May 21, 2025
Blockchain gaming is ‘growing up’
Softwares

Blockchain gaming is ‘growing up’

by admin
May 19, 2025
Next Post
Women in tech | bol.com

Reducing the Cloud Carbon Footprint of bol. | Blog | bol.com

This great GoPro camera bundle is $250 cheaper for Prime Day

Save $100 with this GoPro Hero 10 Black Prime Day bundle

  • Trending
  • Comments
  • Latest
barnacle boi Releases Thumping ‘Introspect’ EP

barnacle boi Releases Thumping ‘Introspect’ EP

November 15, 2023
Australian Music Festival Forced to Cancel Due to 529% Government-Imposed Price Hike: Report

Australian Music Festival Forced to Cancel Due to 529% Government-Imposed Price Hike: Report

May 9, 2024
JetBrains Space Review | Developer.com JetBrains Space IDE Review

JetBrains Space Review | Developer.com JetBrains Space IDE Review

July 19, 2023
Most Useful Gadgets in 2021 – Nogentech.org

Most Useful Gadgets in 2021 – Nogentech.org

July 29, 2021
I Tried Calocurb For 90 Days. Here’s My Review.

I Tried Calocurb For 90 Days. Here’s My Review.

January 8, 2025
The Wellness Gift Guide for Every Occasion

The Wellness Gift Guide for Every Occasion

August 23, 2022
User Guide- BigCommerce Product Combo and BOGO Application

User Guide- BigCommerce Product Combo and BOGO Application

October 10, 2022
Unveiling 15+ Essential Tools & Resources for Web Designers and Agencies in 2023

Unveiling 15+ Essential Tools & Resources for Web Designers and Agencies in 2023

September 19, 2023
Verification framework uncovers safety lapses in open-source self-driving system

Verification framework uncovers safety lapses in open-source self-driving system

May 23, 2025
Fans React – First I Prevail Song Since Brian Burkheiser Split

Fans React – First I Prevail Song Since Brian Burkheiser Split

May 23, 2025
A two-pack of Blink Mini 2 security cameras is only $38 for Memorial Day

A two-pack of Blink Mini 2 security cameras is only $38 for Memorial Day

May 23, 2025
Guy Ritchie’s new movie called ‘one of the worst films of the year’ after huge streaming hits

Guy Ritchie’s new movie called ‘one of the worst films of the year’ after huge streaming hits

May 23, 2025
Bybit’s Shunyet on Bitcoin’s ATH: ‘$125K Is Within Reach’ in Q2

Bybit’s Shunyet on Bitcoin’s ATH: ‘$125K Is Within Reach’ in Q2

May 23, 2025
DOOMSDAY and SECRET WARS to December 2026 and 2027 — GeekTyrant

DOOMSDAY and SECRET WARS to December 2026 and 2027 — GeekTyrant

May 23, 2025
Instagram Adds New DM Options, Including Voice Clip Transcription

Instagram Adds New DM Options, Including Voice Clip Transcription

May 23, 2025
How to Buy Nike Us Force 1 Sneakers Online

How to Buy Nike Us Force 1 Sneakers Online

May 22, 2025
New Self New Life

Your source for entertainment news, celebrities, celebrity news, and Music, Cinema, Digital Lifestyle and Social Media and More !

Categories

  • Celebrity
  • Cinema
  • Devices
  • Digital Lifestyle
  • Entertainment
  • Music
  • Social Media
  • Softwares
  • Uncategorized

Recent Posts

  • Verification framework uncovers safety lapses in open-source self-driving system
  • Fans React – First I Prevail Song Since Brian Burkheiser Split
  • A two-pack of Blink Mini 2 security cameras is only $38 for Memorial Day
  • Home
  • Disclaimer
  • DMCA
  • Privacy Policy
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2021 New Self New Life.
New Self New Life is not responsible for the content of external sites. slotsfree  creator solana token

No Result
View All Result
  • Home
  • Entertainment
  • Celebrity
  • Cinema
  • Music
  • Digital Lifestyle
  • Social Media
  • Softwares
  • Devices

Copyright © 2021 New Self New Life.
New Self New Life is not responsible for the content of external sites.

boss77 login register