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.
The following is written in their documentation:
v7 should be a pain free upgrade! Although some breaking changes have been made, most applications shouldn't see any effects or need to make any changes in their code.
For this reason, we have not included migration instructions. If you run into a specific issue, please get in touch on the Discord server, where we'll be happy to help you migrate!