@@ -19,9 +19,9 @@ class MyApp extends StatelessWidget {
19
19
}
20
20
21
21
class MyHomePage extends StatefulWidget {
22
- MyHomePage ({Key key, this .title}) : super (key: key);
22
+ MyHomePage ({Key ? key, this .title}) : super (key: key);
23
23
24
- final String title;
24
+ final String ? title;
25
25
26
26
@override
27
27
_MyHomePageState createState () => _MyHomePageState ();
@@ -36,7 +36,7 @@ class _MyHomePageState extends State<MyHomePage> {
36
36
appBar: AppBar (
37
37
// Here we take the value from the MyHomePage object that was created by
38
38
// the App.build method, and use it to set our appbar title.
39
- title: Text (widget.title),
39
+ title: Text (widget.title ?? "" ),
40
40
),
41
41
body: Center (
42
42
// Center is a layout widget. It takes a single child and positions it
@@ -70,23 +70,48 @@ class _MyHomePageState extends State<MyHomePage> {
70
70
return Container (
71
71
padding: EdgeInsets .symmetric (horizontal: 20 ),
72
72
child: GooglePlaceAutoCompleteTextField (
73
- textEditingController: controller,
74
- googleAPIKey: "YOUR_GOOGLE_API_KEY" ,
75
- inputDecoration: InputDecoration (hintText: "Search your location" ),
76
- debounceTime: 800 ,
77
- countries: ["in" , "fr" ],
78
- isLatLngRequired: true ,
79
- getPlaceDetailWithLatLng: (Prediction prediction) {
80
- print ("placeDetails" + prediction.lng.toString ());
81
- },
82
- itmClick: (Prediction prediction) {
83
- controller.text = prediction.description;
73
+ textEditingController: controller,
74
+ googleAPIKey: "YOUR_GOOGLE_API_KEY" ,
75
+ inputDecoration: InputDecoration (
76
+ hintText: "Search your location" ,
77
+ border: InputBorder .none,
78
+ enabledBorder: InputBorder .none,
79
+ ),
80
+ debounceTime: 400 ,
81
+ countries: ["in" , "fr" ],
82
+ isLatLngRequired: false ,
83
+ getPlaceDetailWithLatLng: (Prediction prediction) {
84
+ print ("placeDetails" + prediction.lat.toString ());
85
+ },
86
+
87
+ itemClick: (Prediction prediction) {
88
+ controller.text = prediction.description ?? "" ;
89
+ controller.selection = TextSelection .fromPosition (
90
+ TextPosition (offset: prediction.description? .length ?? 0 ));
91
+ },
92
+ seperatedBuilder: Divider (),
93
+ containerHorizontalPadding: 10 ,
94
+
95
+ // OPTIONAL// If you want to customize list view item builder
96
+ itemBuilder: (context, index, Prediction prediction) {
97
+ return Container (
98
+ padding: EdgeInsets .all (10 ),
99
+ child: Row (
100
+ children: [
101
+ Icon (Icons .location_on),
102
+ SizedBox (
103
+ width: 7 ,
104
+ ),
105
+ Expanded (child: Text ("${prediction .description ??"" }" ))
106
+ ],
107
+ ),
108
+ );
109
+ },
84
110
85
- controller.selection = TextSelection .fromPosition (
86
- TextPosition (offset: prediction.description.length));
87
- }
88
- // default 600 ms ,
89
- ),
111
+ isCrossBtnShown: true ,
112
+
113
+ // default 600 ms ,
114
+ ),
90
115
);
91
116
}
92
117
}
0 commit comments