autocomplete_textfield 1.3.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 87

autocomplete_textfield

An autocomplete textfield for flutter

Pub Package Can Be Found At

Pub Package

Usage

AutoCompleteTextField supports any data type suggestions

new AutoCompleteTextField<YOURDATATYPE>()

The suggestions parameter must have data that matches <YOURDATATYPE>

A global key of type GlobalKey<AutoCompleteTextFieldState<T>> is required so that the clear() method can be called to clear AutoCompleteTextField.

Strings and itemFilter

Filtering is case sensitive so when using strings a common implementation of itemFilter is .
itemFilter: (item, query) { return item.toLowerCase().startsWith(query.toLowerCase()); }

[1.0.0]

Works great published version 1

example/lib/main.dart

import 'package:autocomplete_textfield/autocomplete_textfield.dart';
import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Auto Complete TextField Demo',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  List<String> added = [];
  String currentText = "";
  GlobalKey<AutoCompleteTextFieldState<String>> key = new GlobalKey();

  @override
  Widget build(BuildContext context) {
    var textField = new AutoCompleteTextField<String>(
        decoration: new InputDecoration(
            hintText: "Search Item",
            border: new OutlineInputBorder(
                gapPadding: 0.0, borderRadius: new BorderRadius.circular(16.0)),
            suffixIcon: new Icon(Icons.search)),
        key: key,
        suggestions: [
          "Apple",
          "Armidillo",
          "Actual",
          "Actuary",
          "America",
          "Argentina",
          "Australia",
          "Antarctica",
          "Blueberry",
          "Cheese",
          "Danish",
          "Eclair",
          "Fudge",
          "Granola",
          "Hazelnut",
          "Ice Cream",
          "Jely",
          "Kiwi Fruit",
          "Lamb",
          "Macadamia",
          "Nachos",
          "Oatmeal",
          "Palm Oil",
          "Quail",
          "Rabbit",
          "Salad",
          "T-Bone Steak",
          "Urid Dal",
          "Vanilla",
          "Waffles",
          "Yam",
          "Zest"
        ],
        textChanged: (item) {
          currentText = item;
        },
        itemBuilder: (context, item) {
          return new Padding(
              padding: EdgeInsets.all(8.0), child: new Text(item));
        },
        itemSorter: (a, b) {
          return a.compareTo(b);
        },
        itemFilter: (item, query) {
          return item.toLowerCase().startsWith(query.toLowerCase());
        });

    Column body = new Column(children: [
      new ListTile(
          title: textField,
          trailing: new IconButton(
              icon: new Icon(Icons.add),
              onPressed: () {
                setState(() {
                  added.add(currentText);
                  textField.clear();
                });
              }))
    ]);

    body.children.addAll(added.map((item) {
      return new ListTile(title: new Text(item));
    }));

    return new Scaffold(
        appBar: new AppBar(title: new Text('Auto Complete TextField Demo')),
        body: body);
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  autocomplete_textfield: ^1.3.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:autocomplete_textfield/autocomplete_textfield.dart';
  
Version Uploaded Documentation Archive
1.3.0 Sep 2, 2018 Go to the documentation of autocomplete_textfield 1.3.0 Download autocomplete_textfield 1.3.0 archive
1.2.1 Aug 6, 2018 Go to the documentation of autocomplete_textfield 1.2.1 Download autocomplete_textfield 1.2.1 archive
1.2.0 Jul 14, 2018 Go to the documentation of autocomplete_textfield 1.2.0 Download autocomplete_textfield 1.2.0 archive
1.1.0 Jul 14, 2018 Go to the documentation of autocomplete_textfield 1.1.0 Download autocomplete_textfield 1.1.0 archive
1.0.0 Jul 14, 2018 Go to the documentation of autocomplete_textfield 1.0.0 Download autocomplete_textfield 1.0.0 archive
0.0.2 Jul 14, 2018 Go to the documentation of autocomplete_textfield 0.0.2 Download autocomplete_textfield 0.0.2 archive
0.0.1 Jul 14, 2018 Go to the documentation of autocomplete_textfield 0.0.1 Download autocomplete_textfield 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
75
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]
87
Learn more about scoring.

We analyzed this package on Sep 18, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.3
  • Flutter: 0.8.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

Fix lib/autocomplete_textfield.dart.

Analysis of lib/autocomplete_textfield.dart reported 1 hint:

line 12 col 7: This class inherits from a class marked as @immutable, and therefore should be immutable (all instance fields must be final).

Dependencies

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