[go: nahoru, domu]

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

[google_maps_flutter] Modified README.md to fix minor syntax issues #6631

Merged
merged 6 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
36 changes: 12 additions & 24 deletions packages/google_maps_flutter/google_maps_flutter/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Google Maps for Flutter

<?code-excerpt path-base="excerpts/packages/google_maps_flutter_example"?>

[![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.
Expand Down Expand Up @@ -105,46 +107,33 @@ the `GoogleMap`'s `onMapCreated` callback.

### Sample Usage

<?code-excerpt "readme_sample.dart (MapSample)"?>
```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<MapSample> createState() => MapSampleState();
}

class MapSampleState extends State<MapSample> {
Completer<GoogleMapController> _controller = Completer();
final Completer<GoogleMapController> _controller =
Completer<GoogleMapController>();

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,
zoom: 19.151926040649414);

@override
Widget build(BuildContext context) {
return new Scaffold(
return Scaffold(
body: GoogleMap(
mapType: MapType.hybrid,
initialCameraPosition: _kGooglePlex,
Expand All @@ -154,8 +143,8 @@ class MapSampleState extends State<MapSample> {
),
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),
),
);
}
Expand All @@ -164,7 +153,6 @@ class MapSampleState extends State<MapSample> {
final GoogleMapController controller = await _controller.future;
controller.animateCamera(CameraUpdate.newCameraPosition(_kLake));
}
}
```

See the `example` directory for a complete sample app.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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<MapSample> createState() => MapSampleState();
}

class MapSampleState extends State<MapSample> {
final Completer<GoogleMapController> _controller =
Completer<GoogleMapController>();

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<void> _goToTheLake() async {
final GoogleMapController controller = await _controller.future;
controller.animateCamera(CameraUpdate.newCameraPosition(_kLake));
}
// #enddocregion MapSample
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down