Abrir maps da Google usando Flutter #169
Unanswered
caiolages
asked this question in
Perguntas e Respostas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
olá pessoal,
Criei meu projeto no Google Cloud, habilitei as Apis e criei a API key. Adicionei a API key tanto no Android manifest, quando no IOS app delegate. E copiei o seguinte código para meu main.dart e main.page.
main.dart:
import 'package:b_app/pages/map_pages.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Google Maps Demo',
home: MapPage(),
);
}
}
e a minha main.page:
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
class MapPage extends StatefulWidget {
const MapPage({super.key});
@OverRide
State createState() => _MapPageState();
}
class _MapPageState extends State {
static const LatLng _pGooglePlex = LatLng(37.4223, -122.0848);
@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: GoogleMap(
initialCameraPosition: CameraPosition(
target: _pGooglePlex,
zoom: 13,
),
),
);
}
}
Porém quando eu rodo o comando flutter run, eu recebo a seguinte mensagem:
"The following JSNoSuchMethodError was thrown building GoogleMap(dirty, dependencies:
[Directionality], state: _GoogleMapState#b9d73):
TypeError: Cannot read properties of undefined (reading 'maps')"
Alguém já se deparou com esse erro ao tentar adicionar um mapa do Google maps em um Flutter App?
Beta Was this translation helpful? Give feedback.
All reactions