Raphael Michelassi
Raphael Michelassi

Reputation: 1

GestureDetector on markers of Flutter_map isnt working

I'm trying to create a map using flutter_maps, but when I add a GestureDetector to the markers, some errors appear

          MarkerLayer(
            markers: [
              Marker(
                point: LatLng(-22.3285, -49.0523),
                width: 65,
                height: 50,
                builder: (context) => GestureDetector(
                  onTap: () {
                    //nothing yet
                  },
                child: Container(
                  padding: EdgeInsets.symmetric(horizontal: 4, vertical: 2),
                  decoration: BoxDecoration(
                    color: Colors.black.withOpacity(0.5),
                    borderRadius: BorderRadius.circular(5),
                  ),
                  child: Text(
                    'BLOCOS C, D & E',
                    style: TextStyle(
                      color: Colors.white,
                      fontWeight: FontWeight.bold,
                    ),
                    textAlign: TextAlign.center,
                  ),
                ),
              ),
              ),
            ],
          ),

the errors are "The named parameter 'child' is required, but there's no corresponding argument." and "The named parameter 'builder' isn't defined."

Upvotes: -1

Views: 330

Answers (2)

HWK
HWK

Reputation: 709

You could use something like this:

MarkerList = [ 
Marker(
    point: position,
    width: 22,
    height: 22,
    child: Tooltip(
        message: tooltipText,
        child: InkWell(
            child: SvgPicture.string(svgString),
            onTap: () => setState(() {
              // do something
            })
        )
    )
)

];

Upvotes: 0

jakobleck
jakobleck

Reputation: 179

Well, heed the warning: Instead of builder pass a child to the Marker. According to the doc it does not have a parameter builder: https://pub.dev/documentation/flutter_map/latest/flutter_map/Marker-class.html

Upvotes: 0

Related Questions