MapTooltipSettings class

Customizes the appearance of the bubble's or shape's tooltip.

late MapShapeSource _mapSource;
late List<Model> _data;

@override
void initState() {

   _data = <Model>[
    Model('India', 280, "Low", Colors.red),
    Model('United States of America', 190, "High", Colors.green),
    Model('Pakistan', 37, "Low", Colors.yellow),
   ];

   _mapSource = MapShapeSource.asset(
     "assets/world_map.json",
     shapeDataField: "name",
     dataCount: _data.length,
     primaryValueMapper: (int index) => _data[index].country,
     shapeColorValueMapper: (int index) => _data[index].color
   );

   super.initState();
}

@override
Widget build(BuildContext context) {
  return Scaffold(
     body: Padding(
       padding: EdgeInsets.all(15),
       child: SfMaps(
         layers: <MapLayer>[
           MapShapeLayer(
             source: _mapSource,
             tooltipSettings: MapTooltipSettings(color: Colors.red),
             shapeTooltipBuilder: (BuildContext context, int index) {
               if(index == 0) {
                 return Container(
                   child: Icon(Icons.airplanemode_inactive),
                 );
               }
               else
               {
                 return Container(
                      child: Icon(Icons.airplanemode_active),
                 );
               }
             },
           ),
         ],
       ),
     ),
  );
}

class Model {
 const Model(this.country, this.usersCount, this.storage, this.color);

 final String country;
 final double usersCount;
 final String storage;
 final Color  color;
}

See also:

Inheritance
Annotations

Constructors

MapTooltipSettings({double hideDelay = 3.0, Color? color, double? strokeWidth, Color? strokeColor})
Creates a MapTooltipSettings.
const

Properties

color Color?
Fills the tooltip by this color.
final
hashCode int
The hash code for this object.
no setteroverride
hideDelay double
Specifies the duration of the tooltip visibility.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
strokeColor Color?
Specifies the stroke color applies to the tooltip.
final
strokeWidth double?
Specifies the stroke width applies to the tooltip.
final

Methods

debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A brief description of this object, usually just the runtimeType and the hashCode.
inherited

Operators

operator ==(Object other) bool
The equality operator.
override