simple_autocomplete_search 1.0.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 81

simple_autocomplete_search #

Really simple and easy to use autocomplete field with suggestions. You can customise what happens when item is selected and how filtering is done. Hint text and borders of the widget are also customizable.

Getting Started #

To get plugin up and running, add following to your pubspec.yaml. Check the latest version number from here.

dependencies:
  simple_autocomplete_search: ^1.0.5

Then get the dependencies using the code editor or command line. In command line you can use

$ flutter pub get

and the last step is to import the package to your dart file by adding following line.

import 'package:autocomplete_textfield/autocomplete_textfield.dart';

Pub Package #

See the Pub Package and the latest released version here.

Usage #

Autocomplete works only with a list of strings. It refreshes when it gains focus.

All parameters are optional, making possible that you can test the package by just importing and using:

SimpleAutocompleteSearch()

Following gif demonstrates the bare minimum app with SimpleAutocompleteSearch. The code can be found in examples.

Bare minimum demo

The simplest search bar use will be following:

List<String> myList = ["foo", "bar"];
void myFunction(String text){
    print(text);
}
SimpleAutocompleteSearch(onSelected: myFunction, suggestions: myList);

SimpleAutocompleteSearch can take following parameters:

SimpleAutocompleteSearch(
    onSelected: Function(String),
    suggestions: List<String>,
    filter: Functions(String, String), // First string is suggestion, second is typed characters.
    hint: String,
    border: Border,
    tileMinHeight: double, // default: 50
    tileMaxHeight: double // default: infinity
    hideSuggestionsOnInit: bool // default: true
    )

Filtering function must be in format:

bool myFiltering function(String wholeSuggestion, String typedCharacters)

Following gif is from sample app providing all parameters to SimpleAutocompleteSearch

Bare minimum demo

See the examples to find out more.

Changelog #

[1.0.5]

Somehow forgot to add the corrected file to previous version. Here it is now.

[1.0.4]

Fixed the crash when user does not provide a filtering function.

[1.0.3]

Added hideSuggestionsOnInit optional parameter to hide or show all suggestions when widget is created. Default value is true. Also tileMinHeight and tileMaxHeight parameters added.

[1.0.2]

Fixed some issues about providing callback function as a parameter.

[1.0.1]

Fixed case when user does not give a list to widget.

[1.0.0]

First version. Should work.

example/README.md

Examples folder #

Here are some examples. All examples are placed in unique folder. If you are not in Github, click here to the see examples.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  simple_autocomplete_search: ^1.0.5

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:simple_autocomplete_search/simple_autocomplete_search.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
62
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
81
Learn more about scoring.

We analyzed this package on Mar 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Fix lib/simple_autocomplete_search.dart. (-0.50 points)

Analysis of lib/simple_autocomplete_search.dart reported 1 hint:

line 12 col 7: This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: SimpleAutocompleteSearch.suggestions

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test