offset property

Offset? offset

Places the legend in custom position.

If the offset has been set and if the position is top, then the legend will be placed in top but in the position additional to the actual top position. Also, the legend will not take dedicated position for it and will be drawn on the top of map.

late List<DataModel> _data;
late MapShapeSource _mapSource;

 void initState() {

   _data = <DataModel>[
     DataModel('India', 280, "Low"),
     DataModel('United States of America', 190, "High"),
     DataModel('Pakistan', 37, "Low"),

   _mapSource = MapShapeSource.asset(
     shapeDataField: "name",
     dataCount: _data.length,
     primaryValueMapper: (int index) {
       return _data[index].country;
     shapeColorValueMapper: (int index) {
       return _data[index].storage;
     shapeColorMappers: [
       MapColorMapper(value: "Low", color:,
       MapColorMapper(value: "High", color:

 Widget build(BuildContext context) {
   return Scaffold(
     appBar: AppBar(
       title: Text('Bar legend'),
     body: Center(
       child: SfMaps(
         layers: [
             source: _mapSource,
               offset: Offset(10.0, 10.0),

class DataModel {
  const DataModel(, this.count,;

  final String country;
  final double count;
  final String storage;

See also:

  • position, to set the position of the legend.


final Offset? offset;