targetForSection property

String? get targetForSection

Return a target string that can be used to refer to the given section. In order of preference, this will be:

  • The first ID of the section, if it has any (like id:abcd1234)
  • The first CUSTOM_ID of the section, if it has any (like #foo-bar)
  • The title of the section, if it has one (like *Foo bar)

If the section has none of these, return null.

Implementation

String? get targetForSection {
  final id = ids.firstOrNull;
  if (id != null) {
    return 'id:$id';
  }
  final customId = customIds.firstOrNull;
  if (customId != null) {
    return '#$customId';
  }
  final self = this;
  final title = self is OrgSection ? self.headline.rawTitle : null;
  if (title != null) {
    return '*$title';
  }
  return null;
}