Skip to content

Commit 2bd0efd

Browse files
committed
Example
1 parent 4520b24 commit 2bd0efd

9 files changed

+249
-237
lines changed

.idea/libraries/Dart_Packages.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

+110-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

autocomplete_textfield.iml

+40
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,46 @@
99
<excludeFolder url="file://$MODULE_DIR$/.idea" />
1010
<excludeFolder url="file://$MODULE_DIR$/.pub" />
1111
<excludeFolder url="file://$MODULE_DIR$/build" />
12+
<excludeFolder url="file://$MODULE_DIR$/example/.idea/libraries/packages" />
13+
<excludeFolder url="file://$MODULE_DIR$/example/.idea/packages" />
14+
<excludeFolder url="file://$MODULE_DIR$/example/.idea/runConfigurations/packages" />
15+
<excludeFolder url="file://$MODULE_DIR$/example/.pub" />
16+
<excludeFolder url="file://$MODULE_DIR$/example/android/app/packages" />
17+
<excludeFolder url="file://$MODULE_DIR$/example/android/app/src/main/java/felixmccuaig/example/packages" />
18+
<excludeFolder url="file://$MODULE_DIR$/example/android/app/src/main/java/felixmccuaig/packages" />
19+
<excludeFolder url="file://$MODULE_DIR$/example/android/app/src/main/java/io/flutter/packages" />
20+
<excludeFolder url="file://$MODULE_DIR$/example/android/app/src/main/java/io/flutter/plugins/packages" />
21+
<excludeFolder url="file://$MODULE_DIR$/example/android/app/src/main/java/io/packages" />
22+
<excludeFolder url="file://$MODULE_DIR$/example/android/app/src/main/java/packages" />
23+
<excludeFolder url="file://$MODULE_DIR$/example/android/app/src/main/packages" />
24+
<excludeFolder url="file://$MODULE_DIR$/example/android/app/src/main/res/drawable/packages" />
25+
<excludeFolder url="file://$MODULE_DIR$/example/android/app/src/main/res/mipmap-hdpi/packages" />
26+
<excludeFolder url="file://$MODULE_DIR$/example/android/app/src/main/res/mipmap-mdpi/packages" />
27+
<excludeFolder url="file://$MODULE_DIR$/example/android/app/src/main/res/mipmap-xhdpi/packages" />
28+
<excludeFolder url="file://$MODULE_DIR$/example/android/app/src/main/res/mipmap-xxhdpi/packages" />
29+
<excludeFolder url="file://$MODULE_DIR$/example/android/app/src/main/res/mipmap-xxxhdpi/packages" />
30+
<excludeFolder url="file://$MODULE_DIR$/example/android/app/src/main/res/packages" />
31+
<excludeFolder url="file://$MODULE_DIR$/example/android/app/src/main/res/values/packages" />
32+
<excludeFolder url="file://$MODULE_DIR$/example/android/app/src/packages" />
33+
<excludeFolder url="file://$MODULE_DIR$/example/android/gradle/packages" />
34+
<excludeFolder url="file://$MODULE_DIR$/example/android/gradle/wrapper/packages" />
35+
<excludeFolder url="file://$MODULE_DIR$/example/android/packages" />
36+
<excludeFolder url="file://$MODULE_DIR$/example/build" />
37+
<excludeFolder url="file://$MODULE_DIR$/example/ios/Flutter/packages" />
38+
<excludeFolder url="file://$MODULE_DIR$/example/ios/Runner.xcodeproj/packages" />
39+
<excludeFolder url="file://$MODULE_DIR$/example/ios/Runner.xcodeproj/project.xcworkspace/packages" />
40+
<excludeFolder url="file://$MODULE_DIR$/example/ios/Runner.xcodeproj/xcshareddata/packages" />
41+
<excludeFolder url="file://$MODULE_DIR$/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/packages" />
42+
<excludeFolder url="file://$MODULE_DIR$/example/ios/Runner.xcworkspace/packages" />
43+
<excludeFolder url="file://$MODULE_DIR$/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/packages" />
44+
<excludeFolder url="file://$MODULE_DIR$/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/packages" />
45+
<excludeFolder url="file://$MODULE_DIR$/example/ios/Runner/Assets.xcassets/packages" />
46+
<excludeFolder url="file://$MODULE_DIR$/example/ios/Runner/Base.lproj/packages" />
47+
<excludeFolder url="file://$MODULE_DIR$/example/ios/Runner/packages" />
48+
<excludeFolder url="file://$MODULE_DIR$/example/ios/packages" />
49+
<excludeFolder url="file://$MODULE_DIR$/example/lib/packages" />
50+
<excludeFolder url="file://$MODULE_DIR$/example/packages" />
51+
<excludeFolder url="file://$MODULE_DIR$/example/test/packages" />
1252
<excludeFolder url="file://$MODULE_DIR$/packages" />
1353
<excludeFolder url="file://$MODULE_DIR$/test/packages" />
1454
</content>

example/lib/main.dart

+39-83
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,65 @@
11
import 'package:flutter/material.dart';
2+
import 'package:autocomplete_textfield/autocomplete_textfield.dart';
23

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

56
class MyApp extends StatelessWidget {
6-
// This widget is the root of your application.
77
@override
88
Widget build(BuildContext context) {
99
return new MaterialApp(
10-
title: 'Flutter Demo',
10+
title: 'Auto Complete TextField Demo',
1111
theme: new ThemeData(
12-
// This is the theme of your application.
13-
//
14-
// Try running your application with "flutter run". You'll see the
15-
// application has a blue toolbar. Then, without quitting the app, try
16-
// changing the primarySwatch below to Colors.green and then invoke
17-
// "hot reload" (press "r" in the console where you ran "flutter run",
18-
// or press Run > Flutter Hot Reload in IntelliJ). Notice that the
19-
// counter didn't reset back to zero; the application is not restarted.
2012
primarySwatch: Colors.blue,
2113
),
22-
home: new MyHomePage(title: 'Flutter Demo Home Page'),
14+
home: new MyHomePage(),
2315
);
2416
}
2517
}
2618

2719
class MyHomePage extends StatefulWidget {
28-
MyHomePage({Key key, this.title}) : super(key: key);
29-
30-
// This widget is the home page of your application. It is stateful, meaning
31-
// that it has a State object (defined below) that contains fields that affect
32-
// how it looks.
33-
34-
// This class is the configuration for the state. It holds the values (in this
35-
// case the title) provided by the parent (in this case the App widget) and
36-
// used by the build method of the State. Fields in a Widget subclass are
37-
// always marked "final".
38-
39-
final String title;
40-
4120
@override
4221
_MyHomePageState createState() => new _MyHomePageState();
4322
}
4423

4524
class _MyHomePageState extends State<MyHomePage> {
46-
int _counter = 0;
47-
48-
void _incrementCounter() {
49-
setState(() {
50-
// This call to setState tells the Flutter framework that something has
51-
// changed in this State, which causes it to rerun the build method below
52-
// so that the display can reflect the updated values. If we changed
53-
// _counter without calling setState(), then the build method would not be
54-
// called again, and so nothing would appear to happen.
55-
_counter++;
56-
});
57-
}
58-
5925
@override
6026
Widget build(BuildContext context) {
61-
// This method is rerun every time setState is called, for instance as done
62-
// by the _incrementCounter method above.
63-
//
64-
// The Flutter framework has been optimized to make rerunning build methods
65-
// fast, so that you can just rebuild anything that needs updating rather
66-
// than having to individually change instances of widgets.
27+
Column body = new Column(children: [
28+
new ListTile(
29+
title: new AutoCompleteTextField<String>(
30+
suggestions: [
31+
"Apple",
32+
"Blueberry",
33+
"Cheese",
34+
"Danish",
35+
"Eclair",
36+
"Fudge",
37+
"Granola"
38+
],
39+
textChanged: (item) {
40+
41+
},
42+
itemBuilder: (context, item) {
43+
return new Padding(
44+
padding: EdgeInsets.all(8.0),
45+
child: new Text(item)
46+
);
47+
},
48+
itemSorter: (a, b) {
49+
return a.compareTo(b);
50+
},
51+
itemFilter: (item, query) {
52+
return item.toLowerCase().startsWith(query.toLowerCase());
53+
}),
54+
trailing: new IconButton(icon: new Icon(Icons.add), onPressed: () {
55+
56+
})
57+
58+
)
59+
]);
60+
6761
return new Scaffold(
68-
appBar: new AppBar(
69-
// Here we take the value from the MyHomePage object that was created by
70-
// the App.build method, and use it to set our appbar title.
71-
title: new Text(widget.title),
72-
),
73-
body: new Center(
74-
// Center is a layout widget. It takes a single child and positions it
75-
// in the middle of the parent.
76-
child: new Column(
77-
// Column is also layout widget. It takes a list of children and
78-
// arranges them vertically. By default, it sizes itself to fit its
79-
// children horizontally, and tries to be as tall as its parent.
80-
//
81-
// Invoke "debug paint" (press "p" in the console where you ran
82-
// "flutter run", or select "Toggle Debug Paint" from the Flutter tool
83-
// window in IntelliJ) to see the wireframe for each widget.
84-
//
85-
// Column has various properties to control how it sizes itself and
86-
// how it positions its children. Here we use mainAxisAlignment to
87-
// center the children vertically; the main axis here is the vertical
88-
// axis because Columns are vertical (the cross axis would be
89-
// horizontal).
90-
mainAxisAlignment: MainAxisAlignment.center,
91-
children: <Widget>[
92-
new Text(
93-
'You have pushed the button this many times:',
94-
),
95-
new Text(
96-
'$_counter',
97-
style: Theme.of(context).textTheme.display1,
98-
),
99-
],
100-
),
101-
),
102-
floatingActionButton: new FloatingActionButton(
103-
onPressed: _incrementCounter,
104-
tooltip: 'Increment',
105-
child: new Icon(Icons.add),
106-
), // This trailing comma makes auto-formatting nicer for build methods.
107-
);
62+
appBar: new AppBar(title: new Text('Auto Complete TextField Demo')),
63+
body: body);
10864
}
10965
}

0 commit comments

Comments
 (0)