GEDCOM Structures

Dart Classes for GEDCOM structures (generated from GEDCOM 7 machine-readable specification).
Based on gedcom_codec.

Usage

import 'package:gedcom_codec/gedcom_codec.dart';
import 'package:gedcom_structures/gedcom_7.dart';

void main() {
  final document = GedcomCodec().decode(gedcomString)
              .toGedcom7Document();
  //          ^^^^^^^^^^^^^^^^^
  //         converts [GedcomDocument] to [Gedcom7Document].

  final families = document.getAll<FamilyRecordStructure>();
  //                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  //         allows searching by Dart Type,
  //
  //         e.g. [FamilyRecordStructure] is extending
  //              sealed [Gedcom7Structure], which is also
  //              allows for a proper pattern matching.

  for (final family in families) {
    print(
      'Family ${family.xref}:'
      '\n  husband:${family.husb?.xref}'
      //                    ^^^^
      //     generated structures have getters for corresponding
      //     nested structures as defined in the specification.
      '\n  wife:${family.wife?.xref}'
      '\n  children:${family.chilList.toList()}',
    );
  }

  final individuals = document.getAll<IndividualStructure>();
  for (final individual in individuals) {
    print(
      'Individual ${individual.xref}:'
      '\n  sex: ${individual.sex?.valueText}'
      //                          ^^^^^^^^^
      //     [GedcomStructureValueExtension] on [GedcomStructure] allows
      //     to parse the `payload` as a corresponding type.
      '\n  name: ${individual.nameList.firstOrNull?.valueText}',
    );
  }
}

Additional information

Links:

GEDCOM files sources:

NOTICE:
This work comprises, is based on, or is derived from the FAMILYSEARCH GEDCOM™
Specification, © 1984-2025 Intellectual Reserve, Inc. All rights reserved.
“FAMILYSEARCH GEDCOM™” and “FAMILYSEARCH®” are trademarks of Intellectual
Reserve, Inc. and may not be used except as allowed by the Apache 2.0 license that governs this
work or as expressly authorized in writing and in advance by Intellectual Reserve, Inc.