parseAtlasData method

void parseAtlasData(
  1. Object data
)

Parses the given data to create the texture atlas. The method tries to determine the format of the data by checking if it contains a closing tag for the TextureAtlas element, and if it is not an XML document, an error is thrown. If the data is XML, the parseAtlasXml method is called with the parsed XML document, otherwise an error is thrown.

If data is a string, it can be either an XML document or a JSON object representing the texture atlas. If it is JSON, you can use the dart:convert library to convert it to a Map<String, dynamic> object first before passing it to this method.

Throws an error if the data is not XML or JSON format.

Implementation

void parseAtlasData(Object data) {
  if (data is String) {
    /// parse json or xml.
    if (data.contains('</TextureAtlas>')) {
      data = xml.XmlDocument.parse(data);
    }
  }

  if (data is xml.XmlDocument) {
    parseAtlasXml(data);
  } else {
    throw 'TextureAtlas only supports XML data.';
  }
}