Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
annotations
  • Loading branch information
stuartmorgan-g committed Feb 15, 2021
commit 0afb1790167be80a4dc9773954211a2fce0816ac
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2019, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart=2.9

import 'dart:typed_data';
import 'package:flutter/services.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2019, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart=2.9

import 'dart:async';
import 'dart:io';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,9 @@ class MapUiBodyState extends State<MapUiBody> {
});
}

// Should only be called if _isMapCreated is true.
Widget _nightModeToggler() {
if (!_isMapCreated) {
return null;
}
assert(_isMapCreated);
return TextButton(
child: Text('${_nightMode ? 'disable' : 'enable'} night mode'),
onPressed: () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class MarkerIconsBodyState extends State<MarkerIconsBody> {
target: _kMapCenter,
zoom: 7.0,
),
markers: _createMarker(),
markers: <Marker>{_createMarker()},
onMapCreated: _onMapCreated,
),
),
Expand All @@ -57,14 +57,19 @@ class MarkerIconsBodyState extends State<MarkerIconsBody> {
);
}

Set<Marker> _createMarker() {
return <Marker>{
Marker(
Marker _createMarker() {
if (_markerIcon != null) {
return Marker(
markerId: MarkerId("marker_1"),
position: _kMapCenter,
icon: _markerIcon,
),
};
);
} else {
return Marker(
markerId: MarkerId("marker_1"),
position: _kMapCenter,
);
}
}

Future<void> _createMarkerImageFromAsset(BuildContext context) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PlaceCircleBodyState extends State<PlaceCircleBody> {
PlaceCircleBodyState();

GoogleMapController controller;
Map<CircleId, Circle> circles = <CircleId, Circle>{};
Map<CircleId /*!*/, Circle> circles = <CircleId /*!*/, Circle>{};
int _circleIdCounter = 1;
CircleId selectedCircle;

Expand Down Expand Up @@ -62,12 +62,14 @@ class PlaceCircleBodyState extends State<PlaceCircleBody> {
});
}

void _remove() {
void _remove(CircleId circleId) {
setState(() {
if (circles.containsKey(selectedCircle)) {
circles.remove(selectedCircle);
if (circles.containsKey(circleId)) {
circles.remove(circleId);
}
if (circleId == selectedCircle) {
selectedCircle = null;
}
selectedCircle = null;
});
}

Expand Down Expand Up @@ -100,44 +102,45 @@ class PlaceCircleBodyState extends State<PlaceCircleBody> {
});
}

void _toggleVisible() {
final Circle circle = circles[selectedCircle];
void _toggleVisible(CircleId/*!*/ circleId) {
final Circle/*!*/ circle = circles[circleId];
setState(() {
circles[selectedCircle] = circle.copyWith(
circles[circleId] = circle.copyWith(
visibleParam: !circle.visible,
);
});
}

void _changeFillColor() {
final Circle circle = circles[selectedCircle];
void _changeFillColor(CircleId/*!*/ circleId) {
final Circle/*!*/ circle = circles[circleId];
setState(() {
circles[selectedCircle] = circle.copyWith(
circles[circleId] = circle.copyWith(
fillColorParam: colors[++fillColorsIndex % colors.length],
);
});
}

void _changeStrokeColor() {
final Circle circle = circles[selectedCircle];
void _changeStrokeColor(CircleId/*!*/ circleId) {
final Circle/*!*/ circle = circles[circleId];
setState(() {
circles[selectedCircle] = circle.copyWith(
circles[circleId] = circle.copyWith(
strokeColorParam: colors[++strokeColorsIndex % colors.length],
);
});
}

void _changeStrokeWidth() {
final Circle circle = circles[selectedCircle];
void _changeStrokeWidth(CircleId/*!*/ circleId) {
final Circle/*!*/ circle = circles[circleId];
setState(() {
circles[selectedCircle] = circle.copyWith(
circles[circleId] = circle.copyWith(
strokeWidthParam: widths[++widthsIndex % widths.length],
);
});
}

@override
Widget build(BuildContext context) {
final CircleId selectedId = selectedCircle;
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch,
Expand Down Expand Up @@ -171,34 +174,37 @@ class PlaceCircleBodyState extends State<PlaceCircleBody> {
),
TextButton(
child: const Text('remove'),
onPressed: (selectedCircle == null) ? null : _remove,
onPressed: (selectedId == null)
? null
: () => _remove(selectedId),
),
TextButton(
child: const Text('toggle visible'),
onPressed:
(selectedCircle == null) ? null : _toggleVisible,
onPressed: (selectedId == null)
? null
: () => _toggleVisible(selectedId),
),
],
),
Column(
children: <Widget>[
TextButton(
child: const Text('change stroke width'),
onPressed: (selectedCircle == null)
onPressed: (selectedId == null)
? null
: _changeStrokeWidth,
: () => _changeStrokeWidth(selectedId),
),
TextButton(
child: const Text('change stroke color'),
onPressed: (selectedCircle == null)
onPressed: (selectedId == null)
? null
: _changeStrokeColor,
: () => _changeStrokeColor(selectedId),
),
TextButton(
child: const Text('change fill color'),
onPressed: (selectedCircle == null)
onPressed: (selectedId == null)
? null
: _changeFillColor,
: () => _changeFillColor(selectedId),
),
],
)
Expand Down
Loading