flutterdartfluttermap

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


Solution

  • 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