# Average speed control sections

Last updated:

<!-- -->

October 18, 2026

<!-- -->

\| 3 minutes read

<br />

<br />

An average speed control section is an enforcement zone bounded by an entry gantry and an exit gantry, where the average speed between the two gantries is measured rather than the instantaneous speed. The SDK reports the driver's progress and running average inside such a zone through `SpeedSectionAlarm`.

For instantaneous speed limit monitoring, see [Speed warnings](/docs/flutter/guides/alarms/speed-alarms.md).

## Listen for section events[​](#listen-for-section-events "Direct link to Listen for section events")

The section callbacks carry no arguments and have to read the sections back from the service. Declare the service before the listener and create it afterwards, which is the pattern the SDK itself documents:

```dart
AlarmService? alarmService;

AlarmListener alarmListener = AlarmListener(
    onApproachingSpeedSectionAlarms: () {
        for (final section in alarmService!.approachingSpeedSectionAlarms) {
            showSnackbar("Section control ahead, limit ${section.speedLimit} m/s");
        }
    },
    onEnterSpeedSectionAlarms: () {
        showSnackbar("Entered ${alarmService!.speedSectionAlarms.length} section(s)");
    },
    onTravelSpeedSectionAlarms: () {
        for (final section in alarmService!.speedSectionAlarms) {
            showSnackbar(
                "Average ${section.speedAvg} m/s, ${section.remainingDistance} m left");
        }
    },
    onExitSpeedSectionAlarms: () {
        for (final section in alarmService!.exitedSpeedSectionAlarms) {
            showSnackbar("Left section, final average ${section.speedAvg} m/s");
        }
    },
);

alarmService = AlarmService(alarmListener);

```

## Enable section alarms[​](#enable-section-alarms "Direct link to Enable section alarms")

Section alarms are disabled by default and require the safety cameras overlay to be present in the alarm service `overlays` collection:

```dart
final service = alarmService!;

service.overlays.add(CommonOverlayId.safety.id);
service.enableSpeedSectionAlarm = true;

```

Check the current state with `service.isSpeedSectionAlarmEnabled`.

warning

Section alarms are produced only while navigating with a route. They are not emitted in free drive.

## Read the active sections[​](#read-the-active-sections "Direct link to Read the active sections")

Read the corresponding getter on `AlarmService` to obtain the sections each notification refers to:

| Callback                          | Getter to read                                                                              |
| --------------------------------- | ------------------------------------------------------------------------------------------- |
| `onApproachingSpeedSectionAlarms` | `approachingSpeedSectionAlarms` - sections coming up within the configured `alarmDistance`. |
| `onEnterSpeedSectionAlarms`       | `speedSectionAlarms` - sections the vehicle is currently inside.                            |
| `onTravelSpeedSectionAlarms`      | `speedSectionAlarms` - the same sections, with updated progress.                            |
| `onExitSpeedSectionAlarms`        | `exitedSpeedSectionAlarms` - sections just left behind.                                     |

info

`approachingSpeedSectionAlarms` and `exitedSpeedSectionAlarms` are guaranteed not to be empty when read from their own notification.

`speedSectionAlarms` carries no such guarantee: it returns the sections currently active, and an empty list when none are. Iterate it rather than indexing into it.

warning

Overlay-based alarms need an active `GemMap`, and the loaded map style must contain the safety overlay. Without both, the section alarms do not work correctly.

## SpeedSectionAlarm[​](#speedsectionalarm "Direct link to SpeedSectionAlarm")

| Property            | Type          | Description                                                         |
| ------------------- | ------------- | ------------------------------------------------------------------- |
| `entry`             | `OverlayItem` | The section entry gantry overlay item.                              |
| `exit`              | `OverlayItem` | The section exit gantry overlay item.                               |
| `totalDistance`     | `int`         | Total enforced section length, in meters.                           |
| `remainingDistance` | `int`         | Remaining distance to the exit gantry, in meters.                   |
| `speedLimit`        | `double`      | Enforced section speed limit, in meters per second.                 |
| `speedAvg`          | `double`      | Running average speed since the entry gantry, in meters per second. |

Compare `speedAvg` against `speedLimit` to warn the driver while there is still distance left to compensate:

```dart
for (final section in alarmService!.speedSectionAlarms) {
    if (section.speedAvg > section.speedLimit) {
        showSnackbar(
            "Over the section average, ${section.remainingDistance} m to the exit gantry");
    }
}

```
