skip to Main Content

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."

2

Answers


  1. 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

    Login or Signup to reply.
  2. 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
                })
            )
        )
    )
    

    ];

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search