I recently upgraded my flutter_map version from 3.0.0 to 7.0.2 and a lot of errors appeared on the old I have. How do do I upgrade the current code I have to the latest package version.
Below is the code:
import 'package:flutter/material.dart';
import 'package:flutter_map/plugin_api.dart';
class FlutterMapZoomButtons extends StatelessWidget {
final double minZoom;
final double maxZoom;
final bool mini;
final double padding;
final Alignment alignment;
final Color? zoomInColor;
final Color? zoomInColorIcon;
final Color? zoomOutColor;
final Color? zoomOutColorIcon;
final IconData zoomInIcon;
final IconData zoomOutIcon;
final FitBoundsOptions options =
const FitBoundsOptions(padding: EdgeInsets.all(12));
const FlutterMapZoomButtons({
// super.key,
this.minZoom = 1,
this.maxZoom = 18,
this.mini = true,
this.padding = 2.0,
this.alignment = Alignment.topRight,
this.zoomInColor,
this.zoomInColorIcon,
this.zoomInIcon = Icons.zoom_in,
this.zoomOutColor,
this.zoomOutColorIcon,
this.zoomOutIcon = Icons.zoom_out,
});
@override
Widget build(BuildContext context) {
final map = FlutterMapState.maybeOf(context);
return Align(
alignment: alignment,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(
padding:
EdgeInsets.only(left: padding, top: padding, right: padding),
child: FloatingActionButton(
heroTag: 'zoomInButton',
mini: mini,
backgroundColor: zoomInColor ?? Colors.white.withOpacity(0.8),
onPressed: () {
final bounds = map!.bounds;
final centerZoom = map.getBoundsCenterZoom(bounds, options);
var zoom = centerZoom.zoom + 1;
if (zoom > maxZoom) {
zoom = maxZoom;
}
map.move(centerZoom.center, zoom,
source: MapEventSource.custom);
},
child: Icon(zoomInIcon,
color: zoomInColorIcon ?? IconTheme.of(context).color),
),
),
Padding(
padding: EdgeInsets.all(padding),
child: FloatingActionButton(
heroTag: 'zoomOutButton',
mini: mini,
backgroundColor: zoomOutColor ?? Colors.white.withOpacity(0.8),
onPressed: () {
final bounds = map!.bounds;
final centerZoom = map.getBoundsCenterZoom(bounds, options);
var zoom = centerZoom.zoom - 1;
if (zoom < minZoom) {
zoom = minZoom;
}
map.move(centerZoom.center, zoom,
source: MapEventSource.custom);
},
child: Icon(zoomOutIcon,
color: zoomOutColorIcon ?? IconTheme.of(context).color),
),
),
],
),
);
}
}
I have googled and checked the changelog but I don't find anything helpful. I will be very glad if anyone could help me. I have spent days on it.