From 41e1177959affaaa770f781bbc1526c8a8d4fef7 Mon Sep 17 00:00:00 2001 From: Julius Alibrown Date: Wed, 17 Jan 2024 00:39:58 +0100 Subject: [PATCH 1/6] added properties - width, height, margin and padding --- lib/src/flutter_google_places.dart | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/src/flutter_google_places.dart b/lib/src/flutter_google_places.dart index a451c36..b41a948 100644 --- a/lib/src/flutter_google_places.dart +++ b/lib/src/flutter_google_places.dart @@ -29,6 +29,10 @@ class PlacesAutocompleteWidget extends StatefulWidget { final InputDecoration? decoration; final TextStyle? textStyle; final ThemeData? themeData; + final double? width; + final double? height; + final EdgeInsetsGeometry? padding; + final EdgeInsetsGeometry? margin; /// optional - sets 'proxy' value in google_maps_webservice /// @@ -73,6 +77,10 @@ class PlacesAutocompleteWidget extends StatefulWidget { this.textStyle, this.themeData, this.resultTextStyle, + this.height, + this.width, + this.margin = const EdgeInsets.symmetric(horizontal: 16.0, vertical: 30.0), + this.padding, }) : super(key: key); @override @@ -142,7 +150,7 @@ class _PlacesAutocompleteOverlayState extends PlacesAutocompleteState { ], ), ), - const Divider() + const Divider(), ], ); @@ -196,7 +204,10 @@ class _PlacesAutocompleteOverlayState extends PlacesAutocompleteState { } final container = Container( - margin: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 30.0), + width: widget.width, + height: widget.height, + padding: widget.padding, + margin: widget.margin, child: Stack( children: [ header, @@ -375,7 +386,7 @@ class PoweredByGoogleImage extends StatelessWidget { : _poweredByGoogleBlack, scale: 2.5, ), - ) + ), ], ); } From d18027b69e7308fa5474f53c1c198fcf5731336f Mon Sep 17 00:00:00 2001 From: Julius Alibrown Date: Wed, 17 Jan 2024 00:57:25 +0100 Subject: [PATCH 2/6] updated .show --- lib/src/flutter_google_places.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/src/flutter_google_places.dart b/lib/src/flutter_google_places.dart index b41a948..060e35a 100644 --- a/lib/src/flutter_google_places.dart +++ b/lib/src/flutter_google_places.dart @@ -582,6 +582,10 @@ class PlacesAutocomplete { TextStyle? textStyle, ThemeData? themeData, TextStyle? resultTextStyle, + double? width, + double? height, + EdgeInsetsGeometry? padding, + EdgeInsetsGeometry? margin, }) { final autoCompleteWidget = PlacesAutocompleteWidget( apiKey: apiKey, @@ -606,6 +610,10 @@ class PlacesAutocomplete { textStyle: textStyle, themeData: themeData, resultTextStyle: resultTextStyle, + width: width, + height: height, + padding: padding, + margin: margin, ); if (mode == Mode.overlay) { From 8d62dfd56c8e5d109b4441b012e34a974ff3e265 Mon Sep 17 00:00:00 2001 From: Julius Alibrown Date: Wed, 17 Jan 2024 23:25:34 +0100 Subject: [PATCH 3/6] fixed issue with resizing, added showContainerBackground --- lib/src/flutter_google_places.dart | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/lib/src/flutter_google_places.dart b/lib/src/flutter_google_places.dart index 060e35a..c3038a1 100644 --- a/lib/src/flutter_google_places.dart +++ b/lib/src/flutter_google_places.dart @@ -33,6 +33,7 @@ class PlacesAutocompleteWidget extends StatefulWidget { final double? height; final EdgeInsetsGeometry? padding; final EdgeInsetsGeometry? margin; + final bool showContainerBackground; /// optional - sets 'proxy' value in google_maps_webservice /// @@ -81,6 +82,7 @@ class PlacesAutocompleteWidget extends StatefulWidget { this.width, this.margin = const EdgeInsets.symmetric(horizontal: 16.0, vertical: 30.0), this.padding, + this.showContainerBackground = false, }) : super(key: key); @override @@ -203,16 +205,21 @@ class _PlacesAutocompleteOverlayState extends PlacesAutocompleteState { ); } - final container = Container( - width: widget.width, - height: widget.height, - padding: widget.padding, - margin: widget.margin, - child: Stack( - children: [ - header, - Padding(padding: const EdgeInsets.only(top: 48.0), child: body), - ], + final container = Center( + child: Container( + width: widget.width, + height: widget.height, + padding: widget.padding, + margin: widget.margin, + color: widget.showContainerBackground + ? theme.dialogBackgroundColor + : null, + child: Stack( + children: [ + header, + Padding(padding: const EdgeInsets.only(top: 48.0), child: body), + ], + ), ), ); @@ -586,6 +593,7 @@ class PlacesAutocomplete { double? height, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, + bool showContainerBackgrond = false, }) { final autoCompleteWidget = PlacesAutocompleteWidget( apiKey: apiKey, @@ -614,6 +622,7 @@ class PlacesAutocomplete { height: height, padding: padding, margin: margin, + showContainerBackground: showContainerBackgrond, ); if (mode == Mode.overlay) { From 81e56b32984c23a7608ef1a6f4cf488a9ebf08a6 Mon Sep 17 00:00:00 2001 From: Julius Alibrown Date: Wed, 17 Jan 2024 23:45:19 +0100 Subject: [PATCH 4/6] added background color --- lib/src/flutter_google_places.dart | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/src/flutter_google_places.dart b/lib/src/flutter_google_places.dart index c3038a1..a5a8160 100644 --- a/lib/src/flutter_google_places.dart +++ b/lib/src/flutter_google_places.dart @@ -34,6 +34,7 @@ class PlacesAutocompleteWidget extends StatefulWidget { final EdgeInsetsGeometry? padding; final EdgeInsetsGeometry? margin; final bool showContainerBackground; + final Color? backgroundColor; /// optional - sets 'proxy' value in google_maps_webservice /// @@ -83,6 +84,7 @@ class PlacesAutocompleteWidget extends StatefulWidget { this.margin = const EdgeInsets.symmetric(horizontal: 16.0, vertical: 30.0), this.padding, this.showContainerBackground = false, + this.backgroundColor, }) : super(key: key); @override @@ -97,6 +99,8 @@ class _PlacesAutocompleteOverlayState extends PlacesAutocompleteState { @override Widget build(BuildContext context) { final theme = widget.themeData ?? Theme.of(context); + final Color backgroundColor = + widget.backgroundColor ?? theme.dialogBackgroundColor; if (widget.mode == Mode.fullscreen) { return Theme( data: theme, @@ -126,7 +130,7 @@ class _PlacesAutocompleteOverlayState extends PlacesAutocompleteState { final header = Column( children: [ Material( - color: theme.dialogBackgroundColor, + color: backgroundColor, borderRadius: BorderRadius.only( topLeft: headerTopLeftBorderRadius, topRight: headerTopRightBorderRadius, @@ -175,7 +179,7 @@ class _PlacesAutocompleteOverlayState extends PlacesAutocompleteState { _response == null || _response!.predictions.isEmpty) { body = Material( - color: theme.dialogBackgroundColor, + color: backgroundColor, borderRadius: BorderRadius.only( bottomLeft: bodyBottomLeftBorderRadius, bottomRight: bodyBottomRightBorderRadius, @@ -189,7 +193,7 @@ class _PlacesAutocompleteOverlayState extends PlacesAutocompleteState { bottomLeft: bodyBottomLeftBorderRadius, bottomRight: bodyBottomRightBorderRadius, ), - color: theme.dialogBackgroundColor, + color: backgroundColor, child: ListBody( children: _response!.predictions .map( @@ -211,9 +215,7 @@ class _PlacesAutocompleteOverlayState extends PlacesAutocompleteState { height: widget.height, padding: widget.padding, margin: widget.margin, - color: widget.showContainerBackground - ? theme.dialogBackgroundColor - : null, + color: widget.showContainerBackground ? backgroundColor : null, child: Stack( children: [ header, @@ -594,6 +596,7 @@ class PlacesAutocomplete { EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, bool showContainerBackgrond = false, + Color? backgroundColor, }) { final autoCompleteWidget = PlacesAutocompleteWidget( apiKey: apiKey, @@ -623,6 +626,7 @@ class PlacesAutocomplete { padding: padding, margin: margin, showContainerBackground: showContainerBackgrond, + backgroundColor: backgroundColor, ); if (mode == Mode.overlay) { From 61f4c12ba2c997156f84e2f41e3a46d4d73673b2 Mon Sep 17 00:00:00 2001 From: Julius Alibrown Date: Wed, 17 Jan 2024 23:52:57 +0100 Subject: [PATCH 5/6] added border radius --- lib/src/flutter_google_places.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/src/flutter_google_places.dart b/lib/src/flutter_google_places.dart index a5a8160..a56483e 100644 --- a/lib/src/flutter_google_places.dart +++ b/lib/src/flutter_google_places.dart @@ -35,6 +35,7 @@ class PlacesAutocompleteWidget extends StatefulWidget { final EdgeInsetsGeometry? margin; final bool showContainerBackground; final Color? backgroundColor; + final BorderRadius? borderRadius; /// optional - sets 'proxy' value in google_maps_webservice /// @@ -85,6 +86,7 @@ class PlacesAutocompleteWidget extends StatefulWidget { this.padding, this.showContainerBackground = false, this.backgroundColor, + this.borderRadius, }) : super(key: key); @override @@ -215,7 +217,10 @@ class _PlacesAutocompleteOverlayState extends PlacesAutocompleteState { height: widget.height, padding: widget.padding, margin: widget.margin, - color: widget.showContainerBackground ? backgroundColor : null, + decoration: BoxDecoration( + color: widget.showContainerBackground ? backgroundColor : null, + borderRadius: widget.borderRadius, + ), child: Stack( children: [ header, @@ -597,6 +602,7 @@ class PlacesAutocomplete { EdgeInsetsGeometry? margin, bool showContainerBackgrond = false, Color? backgroundColor, + BorderRadius? borderRadius, }) { final autoCompleteWidget = PlacesAutocompleteWidget( apiKey: apiKey, @@ -627,6 +633,7 @@ class PlacesAutocomplete { margin: margin, showContainerBackground: showContainerBackgrond, backgroundColor: backgroundColor, + borderRadius: borderRadius, ); if (mode == Mode.overlay) { From 080d84f0b14cc1aeda2ddc50e8496424b92d541a Mon Sep 17 00:00:00 2001 From: Julius Alibrown Date: Mon, 5 Aug 2024 02:07:26 +0100 Subject: [PATCH 6/6] updated packages --- example/lib/main.dart | 6 +++--- lib/flutter_google_places.dart | 2 -- lib/src/flutter_google_places.dart | 24 ++++++++++----------- lib/src/places_autocomplete_field.dart | 6 +++--- lib/src/places_autocomplete_form_field.dart | 14 +++++------- pubspec.yaml | 16 +++++++------- 6 files changed, 30 insertions(+), 38 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index ef99be3..99c9fad 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,9 +1,9 @@ import 'dart:async'; import 'dart:math'; -import 'package:google_api_headers/google_api_headers.dart'; import 'package:flutter/material.dart'; import 'package:flutter_google_places/flutter_google_places.dart'; +import 'package:google_api_headers/google_api_headers.dart'; import 'package:google_maps_webservice/places.dart'; const kGoogleApiKey = "API_KEY"; @@ -173,8 +173,8 @@ class _CustomSearchScaffoldState extends PlacesAutocompleteState { onTap: (p) { displayPrediction(p, context); }, - logo: Row( - children: const [FlutterLogo()], + logo: const Row( + children: [FlutterLogo()], mainAxisAlignment: MainAxisAlignment.center, ), ); diff --git a/lib/flutter_google_places.dart b/lib/flutter_google_places.dart index 8872a28..668c324 100644 --- a/lib/flutter_google_places.dart +++ b/lib/flutter_google_places.dart @@ -1,5 +1,3 @@ -library flutter_google_places; - export 'src/flutter_google_places.dart'; export 'src/places_autocomplete_field.dart'; export 'src/places_autocomplete_form_field.dart'; diff --git a/lib/src/flutter_google_places.dart b/lib/src/flutter_google_places.dart index a56483e..1db776a 100644 --- a/lib/src/flutter_google_places.dart +++ b/lib/src/flutter_google_places.dart @@ -1,5 +1,3 @@ -library flutter_google_places.src; - import 'dart:async'; import 'package:flutter/material.dart'; @@ -71,7 +69,7 @@ class PlacesAutocompleteWidget extends StatefulWidget { this.region, this.logo, this.onError, - Key? key, + super.key, this.proxyBaseUrl, this.httpClient, this.startText, @@ -87,7 +85,7 @@ class PlacesAutocompleteWidget extends StatefulWidget { this.showContainerBackground = false, this.backgroundColor, this.borderRadius, - }) : super(key: key); + }); @override State createState() => @@ -284,11 +282,11 @@ class PlacesAutocompleteResult extends StatefulWidget { final TextStyle? resultTextStyle; const PlacesAutocompleteResult({ - Key? key, + super.key, this.onTap, this.logo, this.resultTextStyle, - }) : super(key: key); + }); @override PlacesAutocompleteResultState createState() => @@ -323,10 +321,10 @@ class AppBarPlacesAutoCompleteTextField extends StatefulWidget { final TextStyle? textStyle; const AppBarPlacesAutoCompleteTextField({ - Key? key, + super.key, this.textDecoration, this.textStyle, - }) : super(key: key); + }); @override AppBarPlacesAutoCompleteTextFieldState createState() => @@ -385,7 +383,7 @@ class PoweredByGoogleImage extends StatelessWidget { static const _poweredByGoogleBlack = "packages/flutter_google_places/assets/google_black.png"; - const PoweredByGoogleImage({Key? key}) : super(key: key); + const PoweredByGoogleImage({super.key}); @override Widget build(BuildContext context) { @@ -412,11 +410,11 @@ class PredictionsListView extends StatelessWidget { final TextStyle? resultTextStyle; const PredictionsListView({ - Key? key, + super.key, required this.predictions, this.onTap, this.resultTextStyle, - }) : super(key: key); + }); @override Widget build(BuildContext context) { @@ -440,11 +438,11 @@ class PredictionTile extends StatelessWidget { final TextStyle? resultTextStyle; const PredictionTile({ - Key? key, + super.key, required this.prediction, this.onTap, this.resultTextStyle, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/lib/src/places_autocomplete_field.dart b/lib/src/places_autocomplete_field.dart index cd16a99..ce01069 100644 --- a/lib/src/places_autocomplete_field.dart +++ b/lib/src/places_autocomplete_field.dart @@ -36,7 +36,7 @@ class PlacesAutocompleteField extends StatefulWidget { /// by the decoration to save space for the labels), set the [decoration] to /// null. const PlacesAutocompleteField({ - Key? key, + super.key, required this.apiKey, this.controller, this.leading, @@ -59,7 +59,7 @@ class PlacesAutocompleteField extends StatefulWidget { this.overlayBorderRadius, this.textStyle, this.textStyleFormField, - }) : super(key: key); + }); /// Controls the text being edited. /// @@ -239,7 +239,7 @@ class LocationAutocompleteFieldState extends State { ), ) else - const SizedBox() + const SizedBox(), ], ); diff --git a/lib/src/places_autocomplete_form_field.dart b/lib/src/places_autocomplete_form_field.dart index 9526ead..bcfcbf0 100644 --- a/lib/src/places_autocomplete_form_field.dart +++ b/lib/src/places_autocomplete_form_field.dart @@ -40,9 +40,9 @@ class PlacesAutocompleteFormField extends FormField { /// to [initalValue] or the empty string. /// /// For documentation about the various parameters, see the [PlacesAutocompleteField] class - /// and [new PlacesAutocompleteField], the constructor. + /// and [PlacesAutocompleteField.new], the constructor. PlacesAutocompleteFormField({ - Key? key, + super.key, required String apiKey, this.controller, Icon? leading, @@ -61,17 +61,13 @@ class PlacesAutocompleteFormField extends FormField { bool? strictbounds, ValueChanged? onError, InputDecoration inputDecoration = const InputDecoration(), - AutovalidateMode autovalidateMode = AutovalidateMode.disabled, - FormFieldSetter? onSaved, - FormFieldValidator? validator, + AutovalidateMode super.autovalidateMode = AutovalidateMode.disabled, + super.onSaved, + super.validator, }) : assert(initialValue == null || controller == null), super( - key: key, initialValue: controller != null ? controller.text : (initialValue ?? ''), - onSaved: onSaved, - validator: validator, - autovalidateMode: autovalidateMode, builder: (FormFieldState field) { final TextFormFieldState state = field as TextFormFieldState; final InputDecoration effectiveDecoration = inputDecoration diff --git a/pubspec.yaml b/pubspec.yaml index 14c8af2..eb488f1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,24 +1,24 @@ name: flutter_google_places -description: Google places autocomplete widgets for flutter. No wrapper, use https://pub.dev/packages/google_maps_webservice +description: Google places autocomplete widgets for flutter. No wrapper, use + https://pub.dev/packages/google_maps_webservice version: 0.4.0 repository: https://github.com/fluttercommunity/flutter_google_places environment: - sdk: '>=2.12.0 <3.0.0' - flutter: ">=1.17.0" + sdk: ">=3.2.3 <4.0.0" dependencies: flutter: sdk: flutter - google_api_headers: ^1.3.0 - google_maps_webservice: ^0.0.20-nullsafety.5 - http: ^0.13.4 - rxdart: ^0.27.5 + google_api_headers: 4.0.3 + google_maps_webservice: ^0.0.19 + http: ^0.13.6 + rxdart: ^0.28.0 dev_dependencies: flutter_test: sdk: flutter - lint: ^1.10.0 + lint: ^2.3.0 flutter: assets: