Coder Social home page Coder Social logo

imtoon / flutter_easy_autocomplete Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cyril-andre/flutter_easy_autocomplete

0.0 0.0 0.0 1.85 MB

Flutter widget to help you manage textfield suggestions - Add management of Object rather than String

License: Other

Objective-C 0.15% Kotlin 0.48% Dart 83.00% Swift 1.56% HTML 14.82%

flutter_easy_autocomplete's Introduction

Easy Autocomplete with Objects

Based on Easy Autocomplete by 4inka this flutter widget handles input autocomplete suggestions for generic types items. Suggestions are given as a List of objet or as a Future (asyncSuggestions).

Preview

Why a new package

The changes I made are breaking some properties and behaviour of the original package. This is why I decided not to pollute it but create a new one. If you need to handle autocomplete for simple strings, use Easy Autocomplete; if you want to autocomplete items of any type, choose Easy Autocomplete with Objects

Example

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Example',
        theme: ThemeData(primarySwatch: Colors.blue),
        home: SafeArea(
            child: Scaffold(
                appBar: AppBar(title: Text('Example')),
                body: Column(
                  children: [
                    Container(
                        padding: EdgeInsets.all(10),
                        alignment: Alignment.center,
                        child: EasyAutocomplete<MyObject>(
                          suggestionsStartWith: true,
                          suggestions: [
                            MyObject(value: 1, text: 'one'),
                            MyObject(value: 2, text: 'two'),
                            MyObject(value: 3, text: 'three'),
                            MyObject(value: 4, text: 'four'),
                            MyObject(value: 5, text: 'five'),
                            MyObject(value: 6, text: 'six'),
                            MyObject(value: 7, text: 'seven'),
                            MyObject(value: 8, text: 'eight'),
                            MyObject(value: 9, text: 'nine'),
                            MyObject(value: 10, text: 'ten'),
                          ],
                          onChangeSelection: (value) => debugPrint('onChangeSelection value: ${value?.value ?? -1}'),
                          itemAsString: (p0) => p0?.text ?? '',
                          compareFn: (p0, p1) => p0?.value == p1?.value,
                        )),
                  ],
                )
              )
            )
      );
  }

flutter_easy_autocomplete's People

Contributors

4inka avatar cyril-andre avatar prateekmedia 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.