How to fix this error?
Error : lib/pages/osmmapstest.dart:17:9: Error: No named parameter with the name 'layers'.
layers: [
/C:/Users/HP/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_map-6.0.0/lib/src/map/widget.dart:29:9: Context: Found this candidate, but the arguments don't match.
const FlutterMap({
My Code :
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';
class MapPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('OpenStreetMaps'),
),
body: FlutterMap(
options: MapOptions(
center: LatLng(51.5, -0.09),
zoom: 13.0,
),
layers: [
TileLayerOptions(
urlTemplate:
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c'],
),
],
),
);
}
}
Pubspec.yaml
flutter_map: ^6.0.0
latlong2: ^0.9.0
How to fix the error?
In
flutter_map
version6.0.0
, you should put aTileLayer
inside its children like this:So basically, change
layers
tochildren
and changeTileLayerOptions
toTileLayer
.