autocomplete_textfield 1.2.0

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

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:flutter/material.dart';
import 'package:autocomplete_textfield/autocomplete_textfield.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.2.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or 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.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]
29
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
15
Learn more about scoring.

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

  • Dart: 2.0.0-dev.69.0
  • pana: 0.11.7
  • Flutter: 0.5.5

Platforms

Detected platforms: unsure

Error(s) prevent platform classification:

Error(s) in lib/autocomplete_textfield.dart: Default values of an optional parameter must be constant.

Issues and suggestions

Fix lib/autocomplete_textfield.dart.

Analysis of lib/autocomplete_textfield.dart failed with 5 errors, 1 hint, including:

line 23 col 3: Undefined class 'TextInputAction'.

line 31 col 29: Default values of an optional parameter must be constant.

line 31 col 29: Undefined name 'TextInputAction'.

line 81 col 7: Undefined class 'TextInputAction'.

line 86 col 7: The named parameter 'textInputAction' isn't defined.

Fix platform conflicts.

Error(s) prevent platform classification:

Error(s) in lib/autocomplete_textfield.dart: Default values of an optional parameter must be constant.

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Running dartdoc failed.

Make sure dartdoc runs without any issues.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <2.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.6 1.14.11
meta 1.1.5 1.1.6
sky_engine 0.0.99
typed_data 1.1.5 1.1.6
vector_math 2.0.6 2.0.7
Dev dependencies
flutter_test