@@ -43,7 +43,6 @@ class PlacesAutocompleteWidget extends StatefulWidget {
4343 /// or custom configuration
4444 final BaseClient ? httpClient;
4545
46-
4746 /// optional - set 'resultTextStyle' value in google_maps_webservice
4847 ///
4948 /// In case of changing the default text style of result's text
@@ -92,17 +91,18 @@ class _PlacesAutocompleteOverlayState extends PlacesAutocompleteState {
9291 return Theme (
9392 data: theme,
9493 child: Scaffold (
95- appBar: AppBar (
96- title: AppBarPlacesAutoCompleteTextField (
97- textDecoration: widget.decoration,
98- textStyle: widget.textStyle,
99- ),
94+ appBar: AppBar (
95+ title: AppBarPlacesAutoCompleteTextField (
96+ textDecoration: widget.decoration,
97+ textStyle: widget.textStyle,
10098 ),
101- body: PlacesAutocompleteResult (
102- onTap: Navigator .of (context).pop,
103- logo: widget.logo,
104- resultTextStyle: widget.resultTextStyle,
105- )),
99+ ),
100+ body: PlacesAutocompleteResult (
101+ onTap: Navigator .of (context).pop,
102+ logo: widget.logo,
103+ resultTextStyle: widget.resultTextStyle,
104+ ),
105+ ),
106106 );
107107 } else {
108108 final headerTopLeftBorderRadius = widget.overlayBorderRadius != null
@@ -113,12 +113,14 @@ class _PlacesAutocompleteOverlayState extends PlacesAutocompleteState {
113113 ? widget.overlayBorderRadius! .topRight
114114 : const Radius .circular (2 );
115115
116- final header = Column (children: < Widget > [
117- Material (
116+ final header = Column (
117+ children: < Widget > [
118+ Material (
118119 color: theme.dialogBackgroundColor,
119120 borderRadius: BorderRadius .only (
120- topLeft: headerTopLeftBorderRadius,
121- topRight: headerTopRightBorderRadius),
121+ topLeft: headerTopLeftBorderRadius,
122+ topRight: headerTopRightBorderRadius,
123+ ),
122124 child: Row (
123125 crossAxisAlignment: CrossAxisAlignment .start,
124126 children: < Widget > [
@@ -132,14 +134,17 @@ class _PlacesAutocompleteOverlayState extends PlacesAutocompleteState {
132134 },
133135 ),
134136 Expanded (
135- child: Padding (
136- child: _textField (context),
137- padding: const EdgeInsets .only (right: 8.0 ),
138- )),
137+ child: Padding (
138+ padding: const EdgeInsets .only (right: 8.0 ),
139+ child: _textField (context),
140+ ),
141+ ),
139142 ],
140- )),
141- const Divider ()
142- ]);
143+ ),
144+ ),
145+ const Divider ()
146+ ],
147+ );
143148
144149 Widget body;
145150
@@ -153,19 +158,19 @@ class _PlacesAutocompleteOverlayState extends PlacesAutocompleteState {
153158
154159 if (_searching) {
155160 body = Stack (
156- children: < Widget > [_Loader ()],
157161 alignment: FractionalOffset .bottomCenter,
162+ children: < Widget > [_Loader ()],
158163 );
159164 } else if (_queryTextController! .text.isEmpty ||
160165 _response == null ||
161166 _response! .predictions.isEmpty) {
162167 body = Material (
163168 color: theme.dialogBackgroundColor,
164- child: widget.logo ?? const PoweredByGoogleImage (),
165169 borderRadius: BorderRadius .only (
166170 bottomLeft: bodyBottomLeftBorderRadius,
167171 bottomRight: bodyBottomRightBorderRadius,
168172 ),
173+ child: widget.logo ?? const PoweredByGoogleImage (),
169174 );
170175 } else {
171176 body = SingleChildScrollView (
@@ -191,15 +196,20 @@ class _PlacesAutocompleteOverlayState extends PlacesAutocompleteState {
191196 }
192197
193198 final container = Container (
194- margin: const EdgeInsets .symmetric (horizontal: 16.0 , vertical: 30.0 ),
195- child: Stack (children: < Widget > [
199+ margin: const EdgeInsets .symmetric (horizontal: 16.0 , vertical: 30.0 ),
200+ child: Stack (
201+ children: < Widget > [
196202 header,
197203 Padding (padding: const EdgeInsets .only (top: 48.0 ), child: body),
198- ]));
204+ ],
205+ ),
206+ );
199207
200208 if (Theme .of (context).platform == TargetPlatform .iOS) {
201209 return Padding (
202- padding: const EdgeInsets .only (top: 8.0 ), child: container);
210+ padding: const EdgeInsets .only (top: 8.0 ),
211+ child: container,
212+ );
203213 }
204214 return container;
205215 }
@@ -214,10 +224,11 @@ class _PlacesAutocompleteOverlayState extends PlacesAutocompleteState {
214224 autofocus: true ,
215225 style: widget.textStyle ??
216226 TextStyle (
217- color: Theme .of (context).brightness == Brightness .light
218- ? Colors .black87
219- : null ,
220- fontSize: 16.0 ),
227+ color: Theme .of (context).brightness == Brightness .light
228+ ? Colors .black87
229+ : null ,
230+ fontSize: 16.0 ,
231+ ),
221232 decoration: widget.decoration ??
222233 InputDecoration (
223234 hintText: widget.hint,
@@ -236,8 +247,9 @@ class _Loader extends StatelessWidget {
236247 @override
237248 Widget build (BuildContext context) {
238249 return Container (
239- constraints: const BoxConstraints (maxHeight: 2.0 ),
240- child: const LinearProgressIndicator ());
250+ constraints: const BoxConstraints (maxHeight: 2.0 ),
251+ child: const LinearProgressIndicator (),
252+ );
241253 }
242254}
243255
@@ -254,10 +266,11 @@ class PlacesAutocompleteResult extends StatefulWidget {
254266 }) : super (key: key);
255267
256268 @override
257- _PlacesAutocompleteResult createState () => _PlacesAutocompleteResult ();
269+ PlacesAutocompleteResultState createState () =>
270+ PlacesAutocompleteResultState ();
258271}
259272
260- class _PlacesAutocompleteResult extends State <PlacesAutocompleteResult > {
273+ class PlacesAutocompleteResultState extends State <PlacesAutocompleteResult > {
261274 @override
262275 Widget build (BuildContext context) {
263276 final state = PlacesAutocompleteWidget .of (context)! ;
@@ -284,31 +297,34 @@ class AppBarPlacesAutoCompleteTextField extends StatefulWidget {
284297 final InputDecoration ? textDecoration;
285298 final TextStyle ? textStyle;
286299
287- const AppBarPlacesAutoCompleteTextField (
288- {Key ? key, this .textDecoration, this .textStyle})
289- : super (key: key);
300+ const AppBarPlacesAutoCompleteTextField ({
301+ Key ? key,
302+ this .textDecoration,
303+ this .textStyle,
304+ }) : super (key: key);
290305
291306 @override
292- _AppBarPlacesAutoCompleteTextFieldState createState () =>
293- _AppBarPlacesAutoCompleteTextFieldState ();
307+ AppBarPlacesAutoCompleteTextFieldState createState () =>
308+ AppBarPlacesAutoCompleteTextFieldState ();
294309}
295310
296- class _AppBarPlacesAutoCompleteTextFieldState
311+ class AppBarPlacesAutoCompleteTextFieldState
297312 extends State <AppBarPlacesAutoCompleteTextField > {
298313 @override
299314 Widget build (BuildContext context) {
300315 final state = PlacesAutocompleteWidget .of (context)! ;
301316
302317 return Container (
303- alignment: Alignment .topLeft,
304- margin: const EdgeInsets .only (top: 4.0 ),
305- child: TextField (
306- controller: state._queryTextController,
307- autofocus: true ,
308- style: widget.textStyle ?? _defaultStyle (),
309- decoration:
310- widget.textDecoration ?? _defaultDecoration (state.widget.hint),
311- ));
318+ alignment: Alignment .topLeft,
319+ margin: const EdgeInsets .only (top: 4.0 ),
320+ child: TextField (
321+ controller: state._queryTextController,
322+ autofocus: true ,
323+ style: widget.textStyle ?? _defaultStyle (),
324+ decoration:
325+ widget.textDecoration ?? _defaultDecoration (state.widget.hint),
326+ ),
327+ );
312328 }
313329
314330 InputDecoration _defaultDecoration (String hint) {
@@ -339,25 +355,29 @@ class _AppBarPlacesAutoCompleteTextFieldState
339355}
340356
341357class PoweredByGoogleImage extends StatelessWidget {
342- final _poweredByGoogleWhite =
358+ static const _poweredByGoogleWhite =
343359 "packages/flutter_google_places/assets/google_white.png" ;
344- final _poweredByGoogleBlack =
360+ static const _poweredByGoogleBlack =
345361 "packages/flutter_google_places/assets/google_black.png" ;
346362
347363 const PoweredByGoogleImage ({Key ? key}) : super (key: key);
348364
349365 @override
350366 Widget build (BuildContext context) {
351- return Row (mainAxisAlignment: MainAxisAlignment .center, children: < Widget > [
352- Padding (
367+ return Row (
368+ mainAxisAlignment: MainAxisAlignment .center,
369+ children: < Widget > [
370+ Padding (
353371 padding: const EdgeInsets .all (16.0 ),
354372 child: Image .asset (
355373 Theme .of (context).brightness == Brightness .light
356374 ? _poweredByGoogleWhite
357375 : _poweredByGoogleBlack,
358376 scale: 2.5 ,
359- ))
360- ]);
377+ ),
378+ )
379+ ],
380+ );
361381 }
362382}
363383
@@ -377,11 +397,13 @@ class PredictionsListView extends StatelessWidget {
377397 Widget build (BuildContext context) {
378398 return ListView (
379399 children: predictions
380- .map ((Prediction p) => PredictionTile (
381- prediction: p,
382- onTap: onTap,
383- resultTextStyle: resultTextStyle,
384- ))
400+ .map (
401+ (Prediction p) => PredictionTile (
402+ prediction: p,
403+ onTap: onTap,
404+ resultTextStyle: resultTextStyle,
405+ ),
406+ )
385407 .toList (),
386408 );
387409 }
@@ -408,9 +430,7 @@ class PredictionTile extends StatelessWidget {
408430 style: resultTextStyle ?? Theme .of (context).textTheme.bodyMedium,
409431 ),
410432 onTap: () {
411- if (onTap != null ) {
412- onTap !(prediction);
413- }
433+ onTap? .call (prediction);
414434 },
415435 );
416436 }
@@ -507,9 +527,7 @@ abstract class PlacesAutocompleteState extends State<PlacesAutocompleteWidget> {
507527 void onResponseError (PlacesAutocompleteResponse res) {
508528 if (! mounted) return ;
509529
510- if (widget.onError != null ) {
511- widget.onError !(res);
512- }
530+ widget.onError? .call (res);
513531 setState (() {
514532 _response = null ;
515533 _searching = false ;
0 commit comments