Created
May 16, 2020 08:16
-
-
Save JosLuna98/c8052d464a5c1b2ca322b89c3c35bee2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)))); | |
}, | |
), | |
), | |
), | |
], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm getting error in AddressSearchField and AddressPoint. I get the address_search_field and google_maps_controller packages. What should i do?