Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit da4321d

Browse files
[google_maps_flutter] Modified README.md to fix minor syntax issues (#6631)
* Refactored Reaadme using code excerpts * Fixes * Updated Upstream and Fixed Test Errors * Re-added temp_exclude_excerpt.yaml back due to Failing Test * Restore deleted changelog entries Co-authored-by: stuartmorgan <[email protected]>
1 parent 1381802 commit da4321d

File tree

6 files changed

+103
-26
lines changed

6 files changed

+103
-26
lines changed

packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 2.2.2
22

3+
* Modified `README.md` to fix minor syntax issues and added Code Excerpt to `README.md`.
34
* Updates code for new analysis options.
45
* Updates code for `no_leading_underscores_for_local_identifiers` lint.
56

packages/google_maps_flutter/google_maps_flutter/README.md

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Google Maps for Flutter
22

3+
<?code-excerpt path-base="excerpts/packages/google_maps_flutter_example"?>
4+
35
[![pub package](https://img.shields.io/pub/v/google_maps_flutter.svg)](https://pub.dev/packages/google_maps_flutter)
46

57
A Flutter plugin that provides a [Google Maps](https://developers.google.com/maps/) widget.
@@ -105,46 +107,33 @@ the `GoogleMap`'s `onMapCreated` callback.
105107

106108
### Sample Usage
107109

110+
<?code-excerpt "readme_sample.dart (MapSample)"?>
108111
```dart
109-
import 'dart:async';
110-
111-
import 'package:flutter/material.dart';
112-
import 'package:google_maps_flutter/google_maps_flutter.dart';
113-
114-
void main() => runApp(MyApp());
115-
116-
class MyApp extends StatelessWidget {
117-
@override
118-
Widget build(BuildContext context) {
119-
return MaterialApp(
120-
title: 'Flutter Google Maps Demo',
121-
home: MapSample(),
122-
);
123-
}
124-
}
125-
126112
class MapSample extends StatefulWidget {
113+
const MapSample({Key? key}) : super(key: key);
114+
127115
@override
128116
State<MapSample> createState() => MapSampleState();
129117
}
130118
131119
class MapSampleState extends State<MapSample> {
132-
Completer<GoogleMapController> _controller = Completer();
120+
final Completer<GoogleMapController> _controller =
121+
Completer<GoogleMapController>();
133122
134-
static final CameraPosition _kGooglePlex = CameraPosition(
123+
static const CameraPosition _kGooglePlex = CameraPosition(
135124
target: LatLng(37.42796133580664, -122.085749655962),
136125
zoom: 14.4746,
137126
);
138127
139-
static final CameraPosition _kLake = CameraPosition(
128+
static const CameraPosition _kLake = CameraPosition(
140129
bearing: 192.8334901395799,
141130
target: LatLng(37.43296265331129, -122.08832357078792),
142131
tilt: 59.440717697143555,
143132
zoom: 19.151926040649414);
144133
145134
@override
146135
Widget build(BuildContext context) {
147-
return new Scaffold(
136+
return Scaffold(
148137
body: GoogleMap(
149138
mapType: MapType.hybrid,
150139
initialCameraPosition: _kGooglePlex,
@@ -154,8 +143,8 @@ class MapSampleState extends State<MapSample> {
154143
),
155144
floatingActionButton: FloatingActionButton.extended(
156145
onPressed: _goToTheLake,
157-
label: Text('To the lake!'),
158-
icon: Icon(Icons.directions_boat),
146+
label: const Text('To the lake!'),
147+
icon: const Icon(Icons.directions_boat),
159148
),
160149
);
161150
}
@@ -164,7 +153,6 @@ class MapSampleState extends State<MapSample> {
164153
final GoogleMapController controller = await _controller.future;
165154
controller.animateCamera(CameraUpdate.newCameraPosition(_kLake));
166155
}
167-
}
168156
```
169157

170158
See the `example` directory for a complete sample app.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
targets:
2+
$default:
3+
sources:
4+
include:
5+
- lib/**
6+
# Some default includes that aren't really used here but will prevent
7+
# false-negative warnings:
8+
- $package$
9+
- lib/$lib$
10+
exclude:
11+
- '**/.*/**'
12+
# - '**/build/**'
13+
# builders:
14+
# code_excerpter|code_excerpter:
15+
# enabled: true
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// ignore_for_file: public_member_api_docs
6+
7+
import 'dart:async';
8+
9+
import 'package:flutter/material.dart';
10+
import 'package:google_maps_flutter/google_maps_flutter.dart';
11+
12+
void main() => runApp(const MyApp());
13+
14+
class MyApp extends StatelessWidget {
15+
const MyApp({Key? key}) : super(key: key);
16+
17+
@override
18+
Widget build(BuildContext context) {
19+
return const MaterialApp(
20+
title: 'Flutter Google Maps Demo',
21+
home: MapSample(),
22+
);
23+
}
24+
}
25+
26+
// #docregion MapSample
27+
class MapSample extends StatefulWidget {
28+
const MapSample({Key? key}) : super(key: key);
29+
30+
@override
31+
State<MapSample> createState() => MapSampleState();
32+
}
33+
34+
class MapSampleState extends State<MapSample> {
35+
final Completer<GoogleMapController> _controller =
36+
Completer<GoogleMapController>();
37+
38+
static const CameraPosition _kGooglePlex = CameraPosition(
39+
target: LatLng(37.42796133580664, -122.085749655962),
40+
zoom: 14.4746,
41+
);
42+
43+
static const CameraPosition _kLake = CameraPosition(
44+
bearing: 192.8334901395799,
45+
target: LatLng(37.43296265331129, -122.08832357078792),
46+
tilt: 59.440717697143555,
47+
zoom: 19.151926040649414);
48+
49+
@override
50+
Widget build(BuildContext context) {
51+
return Scaffold(
52+
body: GoogleMap(
53+
mapType: MapType.hybrid,
54+
initialCameraPosition: _kGooglePlex,
55+
onMapCreated: (GoogleMapController controller) {
56+
_controller.complete(controller);
57+
},
58+
),
59+
floatingActionButton: FloatingActionButton.extended(
60+
onPressed: _goToTheLake,
61+
label: const Text('To the lake!'),
62+
icon: const Icon(Icons.directions_boat),
63+
),
64+
);
65+
}
66+
67+
Future<void> _goToTheLake() async {
68+
final GoogleMapController controller = await _controller.future;
69+
controller.animateCamera(CameraUpdate.newCameraPosition(_kLake));
70+
}
71+
// #enddocregion MapSample
72+
}

packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ dependencies:
2222
google_maps_flutter_platform_interface: ^2.2.1
2323

2424
dev_dependencies:
25+
build_runner: ^2.1.10
2526
espresso: ^0.2.0
2627
flutter_driver:
2728
sdk: flutter

packages/google_maps_flutter/google_maps_flutter/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: google_maps_flutter
22
description: A Flutter plugin for integrating Google Maps in iOS and Android applications.
33
repository: https://github.com/flutter/plugins/tree/main/packages/google_maps_flutter/google_maps_flutter
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
5-
version: 2.2.1
5+
version: 2.2.2
66

77
environment:
88
sdk: ">=2.14.0 <3.0.0"

0 commit comments

Comments
 (0)