This is the code below:
`// Automatic FlutterFlow imports
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/widgets/index.dart'; // Imports other custom widgets
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom widget code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart' as ll;
class DynamicMap extends StatefulWidget {
const DynamicMap({
super.key,
this.width,
this.height,
this.points,
required this.accessToken,
required this.startingPoint,
required this.startingZoom,
});
final double? width;
final double? height;
final List<LatLng>? points;
final String accessToken;
final LatLng startingPoint;
final double startingZoom;
@override
State<DynamicMap> createState() => _DynamicMapState();
}
class _DynamicMapState extends State<DynamicMap> {
List<Marker> allMarkers = [];
@override
void initState() {
super.initState();
addMarkersToMap(widget.points);
}
void addMarkersToMap(List<LatLng>? points) {
for (LatLng point in points!) {
allMarkers.add(
Marker(
point: ll.LatLng(point.latitude, point.longitude),
height: 12,
width: 12,
builder: (BuildContext ctx) => Icon(
Icons.location_pin,
color: Colors.red,
),
),
);
}
}
@override
Widget build(BuildContext context) {
return FlutterMap(
options: MapOptions(
center: ll.LatLng(
widget.startingPoint.latitude, widget.startingPoint.longitude),
zoom: widget.startingZoom,
),
children: [
TileLayer(
urlTemplate:
'https://api.mapbox.com/styles/v1/abdulsgilal579/clv6gzc4k007801o081vja3q9/tiles/256/{z}/{x}/{y}@2x?access_token=${widget.accessToken}',
),
MarkerLayer(
markers: allMarkers,
),
],
);
}
}`
and i am getting these 2 errors:
Erorr 1: The named parameter 'builder' isn't defined. Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'builder'.
Erorr 2: The named parameter 'child' is required, but there's no corresponding argument. Try adding the required argument.
Line 46, Character 9
I tried resolving using CHATGPT but nothing happend.
Instead of
builder: (BuildContext ctx) => Icon(
Icons.location_pin,
color: Colors.red,
),
you need
child: Icon(
Icons.location_pin,
color: Colors.red,
),
This is a change introduced in flutter_map in version 6.0.0 as you can see here https://pub.dev/packages/flutter_map/changelog. If you use older versions you could use the builder that you now have in your code