Skip to content

Instantly share code, notes, and snippets.

@JosLuna98
Created May 16, 2020 08:16
Show Gist options
  • Save JosLuna98/c8052d464a5c1b2ca322b89c3c35bee2 to your computer and use it in GitHub Desktop.
Save JosLuna98/c8052d464a5c1b2ca322b89c3c35bee2 to your computer and use it in GitHub Desktop.
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:address_search_field/address_search_field.dart';
void main() {
runApp(MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(),
));
}
class MyHomePage extends StatelessWidget {
final Completer<GoogleMapController> _googleMapController =
Completer<GoogleMapController>();
@override
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
return Stack(
children: [
GoogleMap(
onMapCreated: (GoogleMapController controller) =>
_googleMapController.complete(controller),
initialCameraPosition: CameraPosition(
target: LatLng(0.0, 0.0),
),
),
Positioned(
top: 10.0,
left: size.width * 0.1,
right: size.width * 0.1,
child: Container(
width: size.width * 0.8,
child: AddressSearchField(
country: "Ecuador",
hintText: "Address",
noResultsText: "No results..",
onDone: (AddressPoint point) async {
if (_googleMapController.isCompleted && point.found)
await (await _googleMapController.future).moveCamera(
CameraUpdate.newCameraPosition(CameraPosition(
target: LatLng(point.latitude, point.latitude))));
},
),
),
),
],
);
}
}
@eloyet
Copy link

eloyet commented Apr 2, 2022

I'm getting error in AddressSearchField and AddressPoint. I get the address_search_field and google_maps_controller packages. What should i do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment