Community.parse constructor

Community.parse(
  1. XmlElement element
)

Factory method to create a new Community instance from an XML element.

The factory constructor takes an XmlElement representing the "media:community" element and extracts its child elements 'media:starRating', 'media:statistics', and 'media:tags'. It uses the 'StarRating.parse', 'Statistics.parse', and 'Tags.parse' methods to create corresponding objects from the child elements and initializes the properties of the Community object with these values.

Implementation

factory Community.parse(XmlElement element) {
  return Community(
    starRating: element
        .findElements('media:starRating')
        .map((e) => StarRating.parse(e))
        .firstOrNull, // Extract the first 'media:starRating' child element if present.
    statistics: element
        .findElements('media:statistics')
        .map((e) => Statistics.parse(e))
        .firstOrNull, // Extract the first 'media:statistics' child element if present.
    tags: element
        .findElements('media:tags')
        .map((e) => Tags.parse(e))
        .firstOrNull, // Extract the first 'media:tags' child element if present.
  );
}