Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The argument type 'Future<void> Function(TapPosition)' can't be assigned to the parameter type 'void Function(TapPosition, LatLng)?'

FlutterMap(
            options: MapOptions(
            onTap: (p) async {
              location = await Geocoder2.getDataFromCoordinates(
                  latitude: p.latitude, longitude: p.longitude, googleMapApiKey: ''));
            print("${location.country}");
              setState((){
                point=p;
              });
            },
            center: LatLng(40, -1),
            zoom: 10.0
          ),

I am trying to use geocoder2 in my flutter app to work with maps. But I am facing this error. If someone could help, that’d be great.

  LatLng point=LatLng(49, -1);
  var location=[];

This is my declaration of variables.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

onTap callback provide tapPosition and point.

typedef TapCallback = void Function(TapPosition tapPosition, LatLng point);

Include another parameters to solve this case like

 onTap: (tapPos, p) async {

More about MapOptions and flutter_map/TapCallback

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading