# List segments and waypoints

> Canonical URL: https://docs.mountaya.com/en/sdks/dart/tables/
> Last updated: 2026-11-27
> Rules for agents: https://docs.mountaya.com/llms.txt#rules-for-agents

List an itinerary's legs and places in Flutter, draw a sparkline, show one place in a WaypointCard, and link the tables to a map.

The tables state an itinerary as a roadbook: a row per leg, and a row per place. They read through the same cache as the [elevation profile](https://docs.mountaya.com/en/sdks/dart/elevation-profile.md).

## List the legs

```dart
import 'package:flutter/widgets.dart';
import 'package:mountaya_client/mountaya_client.dart';
import 'package:mountaya_client/rest_schema.dart' as rest_schema;
import 'package:mountaya_elements_flutter/mountaya_elements_flutter.dart';
import 'package:mountaya_geo/mountaya_geo.dart';

class TourLegs extends StatefulWidget {
  const TourLegs({super.key, required this.mountaya});

  final Mountaya mountaya;

  @override
  State<TourLegs> createState() => _TourLegsState();
}

class _TourLegsState extends State<TourLegs> {
  // Every element over an itinerary reads it once through this cache.
  late final ItineraryResourceCache itineraries = ItineraryResourceCache(
    (id, surface) async => (await widget.mountaya.studio.itineraries.getItinerary(
      itinerary_id: id,
      query: rest_schema.GetItineraryQuery(surface: surface),
    )).data,
  );

  @override
  Widget build(BuildContext context) =>
      ItinerarySegmentTable(cache: itineraries, itineraryId: '0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21');
}
```

The default columns state each leg's name, sparkline, length, and climb and loss over the running totals.

- `SegmentTableColumn`: `segment`, `profile` (the leg's sparkline), `distance`, `elevation`, `altitude` (its band), `duration`, `difficulty`. Default `defaultSegmentTableColumns`: `segment`, `profile`, `distance`, `elevation`.
- `ItinerarySegmentTable(cache:, itineraryId:)` and `ItinerarySegmentTable.engine(engine:)`, as the profile has. `legs:` replaces the itinerary's own legs; `highlighted:` names the leg to tint; `onSegmentTap` is handed a leg's id (`group:<id>` for a group shown as one leg).
- Every row is the platform's touch target and is pressed from a hardware keyboard too. A hover or a tap draws again only the rows whose state changed.
- The rows are Geo's rule `itinerarySegmentRows(series, legs)`, for a table of your own ([geo](https://docs.mountaya.com/en/sdks/dart/geo.md#elevation)).

## List the places

```dart
import 'package:flutter/widgets.dart';
import 'package:mountaya_client/mountaya_client.dart';
import 'package:mountaya_client/rest_schema.dart' as rest_schema;
import 'package:mountaya_elements_flutter/mountaya_elements_flutter.dart';
import 'package:mountaya_geo/mountaya_geo.dart';

class TourPlaces extends StatefulWidget {
  const TourPlaces({super.key, required this.mountaya});

  final Mountaya mountaya;

  @override
  State<TourPlaces> createState() => _TourPlacesState();
}

class _TourPlacesState extends State<TourPlaces> {
  // Every element over an itinerary reads it once through this cache.
  late final ItineraryResourceCache itineraries = ItineraryResourceCache(
    (id, surface) async => (await widget.mountaya.studio.itineraries.getItinerary(
      itinerary_id: id,
      query: rest_schema.GetItineraryQuery(surface: surface),
    )).data,
  );

  // The services the reader picked.
  List<rest_schema.WaypointAmenity> _picked = const [];

  @override
  Widget build(BuildContext context) => ItineraryWaypointTable(
    cache: itineraries,
    itineraryId: '0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21',
    columns: const [
      WaypointTableColumn.waypoint,
      WaypointTableColumn.distance,
      WaypointTableColumn.amenities,
      WaypointTableColumn.cutoff,
    ],
    picked: _picked,
    onPickedChanged: (next) => setState(() => _picked = next),
  );
}
```

A chip per service sits over the rows, and keeps the places offering every service picked.

- `WaypointTableColumn`: `waypoint`, `profile`, `distance`, `elevation`, `altitude`, `amenities`, `cutoff`, `properties`. Default `defaultWaypointTableColumns`: `waypoint`, `profile`, `distance`, `elevation`, `amenities`.
- A row per pass: a place the route passes twice has two rows.
- `picked:` and `onPickedChanged` hoist the services chosen; left out, the table keeps its own. `onWaypointTap` is handed the place's id.
- A cut-off, and a `date` field, are written only by your `formatCutoffAt`, in the device's time zone ([cut-offs](https://docs.mountaya.com/en/sdks/dart/elevation-profile.md#places)).
- `ItineraryWaypointTable.engine(engine:)` renders an engine you made and close.

## Draw a sparkline

`ItinerarySparkline` draws an elevation series small, for a row or a card of your own:

```dart
import 'dart:async';

import 'package:flutter/widgets.dart';
import 'package:mountaya_client/mountaya_client.dart';
import 'package:mountaya_elements_flutter/mountaya_elements_flutter.dart';
import 'package:mountaya_geo/mountaya_geo.dart';

class TourSparkline extends StatefulWidget {
  const TourSparkline({super.key, required this.mountaya});

  final Mountaya mountaya;

  @override
  State<TourSparkline> createState() => _TourSparklineState();
}

class _TourSparklineState extends State<TourSparkline> {
  ElevationSeries? _series;

  @override
  void initState() {
    super.initState();
    unawaited(_read());
  }

  Future<void> _read() async {
    final read = await widget.mountaya.studio.itineraries.getItinerary(
      itinerary_id: '0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21',
    );
    final series = buildElevationSeries(ResolvedItinerary(read.data).geometry);
    if (mounted) setState(() => _series = series);
  }

  @override
  Widget build(BuildContext context) => SizedBox(
    width: 120,
    height: 32,
    child: switch (_series) {
      final series? => ItinerarySparkline(series: series),
      null => const SizedBox.shrink(),
    },
  );
}
```

- `ItinerarySparkline({required ElevationSeries series, ProfileRange? lit, String? color})`: `lit` tints a stretch (a `ProfileRange` of distances in meters), `color` is a CSS hexadecimal colour, the tokens' accent where you name none.
- `buildElevationSeries(geometry, {maxPoints})` is Geo's; `ResolvedItinerary(itinerary)` projects an answer into the `geometry`, `legs`, `waypoints` and `characteristics` every element reads.

## Show one place in a card

`WaypointCard` states one place of the itinerary: its mark and name, its services, when it can be used, how to reach it, its links and its photos:

```dart
import 'dart:async';

import 'package:flutter/widgets.dart';
import 'package:mountaya_client/mountaya_client.dart';
import 'package:mountaya_elements_flutter/mountaya_elements_flutter.dart';
import 'package:mountaya_geo/mountaya_geo.dart';

class TourPlace extends StatefulWidget {
  const TourPlace({super.key, required this.mountaya});

  final Mountaya mountaya;

  @override
  State<TourPlace> createState() => _TourPlaceState();
}

class _TourPlaceState extends State<TourPlace> {
  ItineraryPlace? _place;

  @override
  void initState() {
    super.initState();
    unawaited(_read());
  }

  // The itinerary's first place, as the elements read it.
  Future<void> _read() async {
    final read = await widget.mountaya.studio.itineraries.getItinerary(
      itinerary_id: '0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21',
    );
    final places = ResolvedItinerary(read.data).waypoints;
    if (mounted) setState(() => _place = places.firstOrNull);
  }

  @override
  Widget build(BuildContext context) => switch (_place) {
    final place? => WaypointCard(place: place),
    null => const SizedBox.shrink(),
  };
}
```

- `WaypointCard({required ItineraryPlace place, UnitPreferences? units, formatCutoffAt, photoBuilder, onLinkTap, strings})`. Each section is drawn only where the place states a line.
- A website or a booking page is a link only at a web address, so no script is ever opened. A tap opens the address in the app the device opens it in (the browser, the phone, the mail app), or hands it to `onLinkTap` in place of opening it.
- A photo is drawn by your `photoBuilder(context, photo)`, your own image loader's; where you hand none, it is loaded from its address, only a web address.
- An `ItineraryPlace` comes from `ResolvedItinerary(itinerary).waypoints`, or from `itineraryWaypoints(waypoints)`. The card's facts are Geo's `waypointCard(details, scope, units)`.

## Link a table to a map

Hand a table your map. A row pointed at pins the marker at the leg's end or at the place, and a leg's row lights its leg:

```dart
import 'package:flutter/widgets.dart';
import 'package:mountaya_client/mountaya_client.dart';
import 'package:mountaya_client/rest_schema.dart' as rest_schema;
import 'package:mountaya_elements_flutter/mountaya_elements_flutter.dart';
import 'package:mountaya_geo/mountaya_geo.dart';

class TourRoadbook extends StatefulWidget {
  const TourRoadbook({super.key, required this.mountaya});

  final Mountaya mountaya;

  @override
  State<TourRoadbook> createState() => _TourRoadbookState();
}

class _TourRoadbookState extends State<TourRoadbook> {
  late final MapEngine map = MapEngine(widget.mountaya);
  // Every element over an itinerary reads it once through this cache.
  late final ItineraryResourceCache itineraries = ItineraryResourceCache(
    (id, surface) async => (await widget.mountaya.studio.itineraries.getItinerary(
      itinerary_id: id,
      query: rest_schema.GetItineraryQuery(surface: surface),
    )).data,
  );

  @override
  void dispose() {
    map.close();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) => Column(
    children: [
      Expanded(child: MapView(engine: map)),
      Expanded(
        child: ListView(
          children: [
            ItinerarySegmentTable(cache: itineraries, itineraryId: '0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21', map: map),
            ItineraryWaypointTable(cache: itineraries, itineraryId: '0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21', map: map),
          ],
        ),
      ),
    ],
  );
}
```

- A table and a profile over one map never move or take down each other's marker: each pins under an id of its own (`segmentTableCursorMarkerId`, `waypointTableCursorMarkerId`, `profileCursorMarkerId`), and takes down what it wrote as it leaves.
- `onHover` hands you the row pointed at (`ItinerarySegmentRow`, `ItineraryWaypointRow`), and `null` as it is let go, in place of the map's marker and lit leg. `enabled: false` lets go and drives nothing.
- `showCursorMarker`, `hideCursorMarker` and `writeLegEmphasis` are the rules the elements pin and light with, for a widget of your own.

## Next steps

- [Geo without a map](https://docs.mountaya.com/en/sdks/dart/geo.md): The rows and figures in pure Dart.
- [Turn-by-turn navigation](https://docs.mountaya.com/en/sdks/dart/navigation.md): Follow the itinerary, spoken aloud.
