Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autosearch from a Textfield + dependency upgrade #220

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/src/flutter_google_places.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class PlacesAutocompleteWidget extends StatefulWidget {
final TextStyle? textStyle;
final ThemeData? themeData;


/// optional - sets 'proxy' value in google_maps_webservice
///
/// In case of using a proxy the baseUrl can be set.
Expand Down Expand Up @@ -296,11 +297,15 @@ class PlacesAutocompleteResultState extends State<PlacesAutocompleteResult> {
class AppBarPlacesAutoCompleteTextField extends StatefulWidget {
final InputDecoration? textDecoration;
final TextStyle? textStyle;
final FocusNode? focusNode;
final bool autofocus;

const AppBarPlacesAutoCompleteTextField({
Key? key,
this.textDecoration,
this.textStyle,
this.focusNode,
this.autofocus = true,
}) : super(key: key);

@override
Expand All @@ -319,7 +324,8 @@ class AppBarPlacesAutoCompleteTextFieldState
margin: const EdgeInsets.only(top: 4.0),
child: TextField(
controller: state._queryTextController,
autofocus: true,
autofocus: widget.autofocus,
focusNode: widget.focusNode,
style: widget.textStyle ?? _defaultStyle(),
decoration:
widget.textDecoration ?? _defaultDecoration(state.widget.hint),
Expand Down Expand Up @@ -451,13 +457,15 @@ abstract class PlacesAutocompleteState extends State<PlacesAutocompleteWidget> {
void initState() {
super.initState();

doSearch(widget.startText!);

_queryTextController = TextEditingController(text: widget.startText);
_queryTextController!.selection = TextSelection(
baseOffset: 0,
extentOffset: widget.startText?.length ?? 0,
);

_initPlaces();
_initPlaces().then((value) => doSearch(widget.startText!));
_searching = false;

_queryTextController!.addListener(_onQueryChange);
Expand Down
13 changes: 7 additions & 6 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: flutter_google_places
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
version: 0.5.0

environment:
sdk: '>=2.12.0 <3.0.0'
Expand All @@ -10,15 +9,17 @@ environment:
dependencies:
flutter:
sdk: flutter
google_api_headers: ^1.3.0
google_maps_webservice: ^0.0.20-nullsafety.5
http: ^0.13.4
google_api_headers: ^2.0.0
google_maps_webservice:
git:
url: https://github.com/shkvoretz/google_maps_webservice.git
http: ^1.1.0
rxdart: ^0.27.5

dev_dependencies:
flutter_test:
sdk: flutter
lint: ^1.10.0
lint: ^2.0.1

flutter:
assets:
Expand Down