Flutter_map: Undefined class 'LatLng'

Created on 9 Jul 2020  路  2Comments  路  Source: fleaflet/flutter_map

I'm using 0.10.1 version with example code:

FlutterMap(
                options: new MapOptions(
                  center: new LatLng(51.5, -0.09),
                  zoom: 13.0,
                ),
                layers: [
                  new TileLayerOptions(
                      urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
                      subdomains: ['a', 'b', 'c']
                  ),
                  new MarkerLayerOptions(
                    markers: [
                      new Marker(
                        width: 80.0,
                        height: 80.0,
                        point: LatLng(51.5, -0.09),
                        builder: (ctx) =>
                        new Container(
                          child: new FlutterLogo(),
                        ),
                      ),
                    ],
                  ),
                ],
              )

And getting this error on new LatLng(51.5, -0.09) line:

The constructor returns type 'dynamic' that isn't of expected type 'LatLng'.
Undefined class 'LatLng'.  Try changing the name to the name of an existing class, or creating a class with the name 'LatLng'.

Most helpful comment

Resolved by importing it:

import 'package:latlong/latlong.dart';

All 2 comments

Resolved by importing it:

import 'package:latlong/latlong.dart';

This is how the package was originally designed, since those types are defined in a separate package, we expect users to import that package.

Alternatively, package:latlong/latlong.dart could be exported from package:flutter_map/flutter_map.dart, if that makes more sense.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zozeei picture zozeei  路  4Comments

abhijithvijayan picture abhijithvijayan  路  4Comments

jasonleung101 picture jasonleung101  路  3Comments

rktvsiim picture rktvsiim  路  5Comments

aytunch picture aytunch  路  4Comments