toXmlString method

String toXmlString({
  1. bool pretty = false,
  2. int? level,
  3. String? indent,
  4. String newLine = '\n',
})

Converts tcx object to string in XML format, suitable to be written to a '.tcx' file.

The parameters are passed to the XML formatter, their documentation is copied here for convenience :

If pretty is set to true the output is nicely reformatted, otherwise the tree is emitted verbatim.

The remaining options are used for pretty printing only:

  • The option indent defines the indention of nodes, by default nodes are indented with 2 spaces.
  • The option newLine defines the printing of new lines, by default the standard new-line '\n' character is used.
  • The option level customizes the initial indention level, by default this is 0.

Implementation

String toXmlString({
  bool pretty = false,
  int? level,
  String? indent,
  String newLine = '\n',
}) {
  return _xmlVersionEncoding +
      newLine +
      XmlDocument(
        [_toXmlElement(namespaces: namespacesTcxTrainingCenterDatabase)],
      ).toXmlString(
        pretty: pretty,
        level: level,
        indent: indent,
        newLine: newLine,
      );
}