hideDelay property

double hideDelay
final

Specifies the duration of the tooltip visibility.

The default value of the hideDelay property is 3.

By default, the tooltip will disappear after 3 seconds of inactivity. You can always show the tooltip without hiding it by setting double.infinity to the hideDelay property.

When you perform a zoom/pan operation, a window resize, or a change of orientation, the tooltip will disappear.

late MapShapeSource _mapSource;
late List<DataModel> _data;

@override
void initState() {
  _data = <DataModel>[
    DataModel('Asia', '44,579,000 sq. km.'),
    DataModel('Africa', '30,370,000 sq. km.'),
    DataModel('Europe', '10,180,000 sq. km.'),
    DataModel('North America', '24,709,000 sq. km.'),
    DataModel('South America', '17,840,000 sq. km.'),
    DataModel('Australia', '8,600,000 sq. km.'),
  ];

  _mapSource = MapShapeSource.asset(
    "assets/world_map.json",
    shapeDataField: "continent",
    dataCount: _data.length,
    primaryValueMapper: (int index) => _data[index].continent,
  );
  super.initState();
}

@override
Widget build(BuildContext context) {
  return Scaffold(
    body: SfMaps(
      layers: <MapLayer>[
        MapShapeLayer(
          source: _mapSource,
          tooltipSettings: MapTooltipSettings(
            hideDelay: double.infinity,
          ),
          shapeTooltipBuilder: (BuildContext context, int index) {
            if (index == 0) {
              return Icon(Icons.airplanemode_inactive);
            } else {
              return Icon(Icons.airplanemode_active);
            }
          },
        ),
      ],
    ),
  );
}

class DataModel {
  const DataModel(this.continent, this.area);

  final String continent;
  final String area;
}

Implementation

final double hideDelay;