mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 22:09:06 +00:00
Added Google Maps sample code (#1671)
* Added Google Maps sample code * Updated per @domesticmouse review * Updated dependabot and pubspec for Dart 2.19
This commit is contained in:
62
google_maps/lib/main.dart
Normal file
62
google_maps/lib/main.dart
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
State<MyApp> createState() => _MyAppState();
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> {
|
||||
late GoogleMapController mapController;
|
||||
|
||||
final LatLng _center = const LatLng(-33.86, 151.20);
|
||||
|
||||
void _onMapCreated(GoogleMapController controller) {
|
||||
mapController = controller;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Sydney'),
|
||||
backgroundColor: Colors.green[700],
|
||||
),
|
||||
body: GoogleMap(
|
||||
onMapCreated: _onMapCreated,
|
||||
initialCameraPosition: CameraPosition(
|
||||
target: _center,
|
||||
zoom: 11.0,
|
||||
),
|
||||
markers: {
|
||||
// ignore: prefer_const_constructors
|
||||
Marker(
|
||||
markerId: const MarkerId('Sydney'),
|
||||
position: const LatLng(-33.86, 151.20),
|
||||
)
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user