Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix examples ZoomButtonsPluginOption to check min and max properly #1120

Merged
merged 3 commits into from
Jan 29, 2022
Merged
Changes from 2 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
22 changes: 10 additions & 12 deletions example/lib/pages/zoombuttons_plugin_option.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map/plugin_api.dart';

class ZoomButtonsPluginOption extends LayerOptions {
final int minZoom;
final int maxZoom;
final double minZoom;
final double maxZoom;
final bool mini;
final double padding;
final Alignment alignment;
Expand Down Expand Up @@ -79,12 +79,11 @@ class ZoomButtons extends StatelessWidget {
var bounds = map.getBounds();
var centerZoom = map.getBoundsCenterZoom(bounds, options);
var zoom = centerZoom.zoom + 1;
if (zoom < zoomButtonsOpts.minZoom) {
zoom = zoomButtonsOpts.minZoom as double;
} else {
map.move(centerZoom.center, zoom,
source: MapEventSource.custom);
if (zoom > zoomButtonsOpts.maxZoom) {
zoom = zoomButtonsOpts.maxZoom;
}
map.move(centerZoom.center, zoom,
source: MapEventSource.custom);
},
child: Icon(zoomButtonsOpts.zoomInIcon,
color: zoomButtonsOpts.zoomInColorIcon ??
Expand All @@ -102,12 +101,11 @@ class ZoomButtons extends StatelessWidget {
var bounds = map.getBounds();
var centerZoom = map.getBoundsCenterZoom(bounds, options);
var zoom = centerZoom.zoom - 1;
if (zoom > zoomButtonsOpts.maxZoom) {
zoom = zoomButtonsOpts.maxZoom as double;
} else {
map.move(centerZoom.center, zoom,
source: MapEventSource.custom);
if (zoom < zoomButtonsOpts.minZoom) {
zoom = zoomButtonsOpts.minZoom;
}
map.move(centerZoom.center, zoom,
source: MapEventSource.custom);
},
child: Icon(zoomButtonsOpts.zoomOutIcon,
color: zoomButtonsOpts.zoomOutColorIcon ??
Expand Down