Skip to content

Commit

Permalink
Update deprecated patterns to fix CI static analysis (#568)
Browse files Browse the repository at this point in the history
  • Loading branch information
shroff committed Mar 15, 2021
1 parent ec7145e commit 108d6bb
Show file tree
Hide file tree
Showing 10 changed files with 261 additions and 223 deletions.
60 changes: 33 additions & 27 deletions example/lib/animate_camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,38 @@ class AnimateCameraState extends State<AnimateCamera> {
children: <Widget>[
Column(
children: <Widget>[
FlatButton(
TextButton(
onPressed: () {
mapController.animateCamera(
CameraUpdate.newCameraPosition(
const CameraPosition(
bearing: 270.0,
target: LatLng(51.5160895, -0.1294527),
tilt: 30.0,
zoom: 17.0,
),
),
).then((result)=>print("mapController.animateCamera() returned $result"));
mapController
.animateCamera(
CameraUpdate.newCameraPosition(
const CameraPosition(
bearing: 270.0,
target: LatLng(51.5160895, -0.1294527),
tilt: 30.0,
zoom: 17.0,
),
),
)
.then((result) => print(
"mapController.animateCamera() returned $result"));
},
child: const Text('newCameraPosition'),
),
FlatButton(
TextButton(
onPressed: () {
mapController.animateCamera(
CameraUpdate.newLatLng(
const LatLng(56.1725505, 10.1850512),
),
).then((result)=>print("mapController.animateCamera() returned $result"));
mapController
.animateCamera(
CameraUpdate.newLatLng(
const LatLng(56.1725505, 10.1850512),
),
)
.then((result) => print(
"mapController.animateCamera() returned $result"));
},
child: const Text('newLatLng'),
),
FlatButton(
TextButton(
onPressed: () {
mapController.animateCamera(
CameraUpdate.newLatLngBounds(
Expand All @@ -95,7 +101,7 @@ class AnimateCameraState extends State<AnimateCamera> {
},
child: const Text('newLatLngBounds'),
),
FlatButton(
TextButton(
onPressed: () {
mapController.animateCamera(
CameraUpdate.newLatLngZoom(
Expand All @@ -106,7 +112,7 @@ class AnimateCameraState extends State<AnimateCamera> {
},
child: const Text('newLatLngZoom'),
),
FlatButton(
TextButton(
onPressed: () {
mapController.animateCamera(
CameraUpdate.scrollBy(150.0, -225.0),
Expand All @@ -118,7 +124,7 @@ class AnimateCameraState extends State<AnimateCamera> {
),
Column(
children: <Widget>[
FlatButton(
TextButton(
onPressed: () {
mapController.animateCamera(
CameraUpdate.zoomBy(
Expand All @@ -129,47 +135,47 @@ class AnimateCameraState extends State<AnimateCamera> {
},
child: const Text('zoomBy with focus'),
),
FlatButton(
TextButton(
onPressed: () {
mapController.animateCamera(
CameraUpdate.zoomBy(-0.5),
);
},
child: const Text('zoomBy'),
),
FlatButton(
TextButton(
onPressed: () {
mapController.animateCamera(
CameraUpdate.zoomIn(),
);
},
child: const Text('zoomIn'),
),
FlatButton(
TextButton(
onPressed: () {
mapController.animateCamera(
CameraUpdate.zoomOut(),
);
},
child: const Text('zoomOut'),
),
FlatButton(
TextButton(
onPressed: () {
mapController.animateCamera(
CameraUpdate.zoomTo(16.0),
);
},
child: const Text('zoomTo'),
),
FlatButton(
TextButton(
onPressed: () {
mapController.animateCamera(
CameraUpdate.bearingTo(45.0),
);
},
child: const Text('bearingTo'),
),
FlatButton(
TextButton(
onPressed: () {
mapController.animateCamera(
CameraUpdate.tiltTo(30.0),
Expand Down
9 changes: 4 additions & 5 deletions example/lib/generated_plugin_registrant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
// Generated file. Do not edit.
//

// ignore: unused_import
import 'dart:ui';
// ignore_for_file: lines_longer_than_80_chars

import 'package:mapbox_gl_web/mapbox_gl_web.dart';

import 'package:flutter_web_plugins/flutter_web_plugins.dart';

// ignore: public_member_api_docs
void registerPlugins(PluginRegistry registry) {
MapboxMapPlugin.registerWith(registry.registrarFor(MapboxMapPlugin));
registry.registerMessageHandler();
void registerPlugins(Registrar registrar) {
MapboxMapPlugin.registerWith(registrar);
registrar.registerMessageHandler();
}
53 changes: 25 additions & 28 deletions example/lib/line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,16 @@ class LineBodyState extends State<LineBody> {
void _add() {
controller.addLine(
LineOptions(
geometry: [
LatLng(-33.86711, 151.1947171),
LatLng(-33.86711, 151.1947171),
LatLng(-32.86711, 151.1947171),
LatLng(-33.86711, 152.1947171),
],
lineColor: "#ff0000",
lineWidth: 14.0,
lineOpacity: 0.5,
draggable: true
),
geometry: [
LatLng(-33.86711, 151.1947171),
LatLng(-33.86711, 151.1947171),
LatLng(-32.86711, 151.1947171),
LatLng(-33.86711, 152.1947171),
],
lineColor: "#ff0000",
lineWidth: 14.0,
lineOpacity: 0.5,
draggable: true),
);
setState(() {
_lineCount += 1;
Expand All @@ -96,7 +95,6 @@ class LineBodyState extends State<LineBody> {
});
}


Future<void> _changeAlpha() async {
double current = _selectedLine.options.lineOpacity;
if (current == null) {
Expand All @@ -123,10 +121,7 @@ class LineBodyState extends State<LineBody> {
void onStyleLoadedCallback() {
controller.addLine(
LineOptions(
geometry: [
LatLng(37.4220, -122.0841),
LatLng(37.4240, -122.0941)
],
geometry: [LatLng(37.4220, -122.0841), LatLng(37.4240, -122.0941)],
lineColor: "#ff0000",
lineWidth: 14.0,
lineOpacity: 0.5,
Expand Down Expand Up @@ -164,37 +159,39 @@ class LineBodyState extends State<LineBody> {
children: <Widget>[
Column(
children: <Widget>[
FlatButton(
TextButton(
child: const Text('add'),
onPressed: (_lineCount == 12) ? null : _add,
),
FlatButton(
TextButton(
child: const Text('remove'),
onPressed: (_selectedLine == null) ? null : _remove,
),
],
),
Column(
children: <Widget>[
FlatButton(
TextButton(
child: const Text('change alpha'),
onPressed:
(_selectedLine == null) ? null : _changeAlpha,
),
FlatButton(
TextButton(
child: const Text('toggle visible'),
onPressed:
(_selectedLine == null) ? null : _toggleVisible,
),
FlatButton(
TextButton(
child: const Text('print current LatLng'),
onPressed:
(_selectedLine == null) ? null : () async{
var latLngs = await controller.getLineLatLngs(_selectedLine);
for (var latLng in latLngs) {
print(latLng.toString());
}
},
onPressed: (_selectedLine == null)
? null
: () async {
var latLngs = await controller
.getLineLatLngs(_selectedLine);
for (var latLng in latLngs) {
print(latLng.toString());
}
},
),
],
),
Expand Down
Loading

0 comments on commit 108d6bb

Please sign in to comment.