diff --git a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md index 4d0164603c42..af701d542029 100644 --- a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 2.2.2 +* Modified `README.md` to fix minor syntax issues and added Code Excerpt to `README.md`. * Updates code for new analysis options. * Updates code for `no_leading_underscores_for_local_identifiers` lint. diff --git a/packages/google_maps_flutter/google_maps_flutter/README.md b/packages/google_maps_flutter/google_maps_flutter/README.md index 58726a1faaa1..b3e3d9bc8333 100644 --- a/packages/google_maps_flutter/google_maps_flutter/README.md +++ b/packages/google_maps_flutter/google_maps_flutter/README.md @@ -1,5 +1,7 @@ # Google Maps for Flutter + + [![pub package](https://img.shields.io/pub/v/google_maps_flutter.svg)](https://pub.dev/packages/google_maps_flutter) A Flutter plugin that provides a [Google Maps](https://developers.google.com/maps/) widget. @@ -105,38 +107,25 @@ the `GoogleMap`'s `onMapCreated` callback. ### Sample Usage + ```dart -import 'dart:async'; - -import 'package:flutter/material.dart'; -import 'package:google_maps_flutter/google_maps_flutter.dart'; - -void main() => runApp(MyApp()); - -class MyApp extends StatelessWidget { - @override - Widget build(BuildContext context) { - return MaterialApp( - title: 'Flutter Google Maps Demo', - home: MapSample(), - ); - } -} - class MapSample extends StatefulWidget { + const MapSample({Key? key}) : super(key: key); + @override State createState() => MapSampleState(); } class MapSampleState extends State { - Completer _controller = Completer(); + final Completer _controller = + Completer(); - static final CameraPosition _kGooglePlex = CameraPosition( + static const CameraPosition _kGooglePlex = CameraPosition( target: LatLng(37.42796133580664, -122.085749655962), zoom: 14.4746, ); - static final CameraPosition _kLake = CameraPosition( + static const CameraPosition _kLake = CameraPosition( bearing: 192.8334901395799, target: LatLng(37.43296265331129, -122.08832357078792), tilt: 59.440717697143555, @@ -144,7 +133,7 @@ class MapSampleState extends State { @override Widget build(BuildContext context) { - return new Scaffold( + return Scaffold( body: GoogleMap( mapType: MapType.hybrid, initialCameraPosition: _kGooglePlex, @@ -154,8 +143,8 @@ class MapSampleState extends State { ), floatingActionButton: FloatingActionButton.extended( onPressed: _goToTheLake, - label: Text('To the lake!'), - icon: Icon(Icons.directions_boat), + label: const Text('To the lake!'), + icon: const Icon(Icons.directions_boat), ), ); } @@ -164,7 +153,6 @@ class MapSampleState extends State { final GoogleMapController controller = await _controller.future; controller.animateCamera(CameraUpdate.newCameraPosition(_kLake)); } -} ``` See the `example` directory for a complete sample app. diff --git a/packages/google_maps_flutter/google_maps_flutter/example/build.excerpt.yaml b/packages/google_maps_flutter/google_maps_flutter/example/build.excerpt.yaml new file mode 100644 index 000000000000..2102d25a193c --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/build.excerpt.yaml @@ -0,0 +1,15 @@ +targets: + $default: + sources: + include: + - lib/** + # Some default includes that aren't really used here but will prevent + # false-negative warnings: + - $package$ + - lib/$lib$ + exclude: + - '**/.*/**' + # - '**/build/**' + # builders: + # code_excerpter|code_excerpter: + # enabled: true \ No newline at end of file diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/readme_sample.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/readme_sample.dart new file mode 100644 index 000000000000..a15639893515 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/readme_sample.dart @@ -0,0 +1,72 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// ignore_for_file: public_member_api_docs + +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; + +void main() => runApp(const MyApp()); + +class MyApp extends StatelessWidget { + const MyApp({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return const MaterialApp( + title: 'Flutter Google Maps Demo', + home: MapSample(), + ); + } +} + +// #docregion MapSample +class MapSample extends StatefulWidget { + const MapSample({Key? key}) : super(key: key); + + @override + State createState() => MapSampleState(); +} + +class MapSampleState extends State { + final Completer _controller = + Completer(); + + static const CameraPosition _kGooglePlex = CameraPosition( + target: LatLng(37.42796133580664, -122.085749655962), + zoom: 14.4746, + ); + + static const CameraPosition _kLake = CameraPosition( + bearing: 192.8334901395799, + target: LatLng(37.43296265331129, -122.08832357078792), + tilt: 59.440717697143555, + zoom: 19.151926040649414); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: GoogleMap( + mapType: MapType.hybrid, + initialCameraPosition: _kGooglePlex, + onMapCreated: (GoogleMapController controller) { + _controller.complete(controller); + }, + ), + floatingActionButton: FloatingActionButton.extended( + onPressed: _goToTheLake, + label: const Text('To the lake!'), + icon: const Icon(Icons.directions_boat), + ), + ); + } + + Future _goToTheLake() async { + final GoogleMapController controller = await _controller.future; + controller.animateCamera(CameraUpdate.newCameraPosition(_kLake)); + } + // #enddocregion MapSample +} diff --git a/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml index ce6819c190db..06bfbbf290e4 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml @@ -22,6 +22,7 @@ dependencies: google_maps_flutter_platform_interface: ^2.2.1 dev_dependencies: + build_runner: ^2.1.10 espresso: ^0.2.0 flutter_driver: sdk: flutter diff --git a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml index 540f5d810966..a037f614f2ac 100644 --- a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter description: A Flutter plugin for integrating Google Maps in iOS and Android applications. repository: https://github.com/flutter/plugins/tree/main/packages/google_maps_flutter/google_maps_flutter issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 -version: 2.2.1 +version: 2.2.2 environment: sdk: ">=2.14.0 <3.0.0"