toGedcomString method

String toGedcomString({
  1. bool recursive = false,
})

Formats this element and optionally all of its subelements to GEDCOM string

Implementation

String toGedcomString({bool recursive = false}) {
  var result = '$level';

  if (pointer != null && pointer!.isNotEmpty) {
    result += ' $pointer';
  }

  result += ' $tag';

  if (value != null && value!.isNotEmpty) {
    result += ' $value';
  }

  result += crlf!;

  if (level < 0) {
    result = '';
  }

  if (recursive == true) {
    for (final element in children) {
      result += element.toGedcomString(recursive: true);
    }
  }

  return result;
}