Group.parse constructor

Group.parse(
  1. XmlElement element
)

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

The factory constructor takes an XmlElement representing the "media:group" element and extracts its child elements "media:content", "media:credit", "media:category", "media:rating", "media:thumbnail", "media:title", and "media:description". It uses these values to initialize the properties of the Group object.

Implementation

factory Group.parse(XmlElement element) {
  return Group(
    contents: element
        .findElements(
            'media:content') // Find all child "media:content" elements.
        .map((e) => Content.parse(
            e)) // Convert each child element to a Content object.
        .toList(), // Convert the iterable to a list.
    credits: element
        .findElements(
            'media:credit') // Find all child "media:credit" elements.
        .map((e) =>
            Credit.parse(e)) // Convert each child element to a Credit object.
        .toList(), // Convert the iterable to a list.
    category: element
        .findElements(
            'media:category') // Find the child "media:category" element.
        .map((e) => Category.parse(
            e)) // Convert the child element to a Category object.
        .firstOrNull, // Get the first Category object or null if not found.
    rating: element
        .findElements(
            'media:rating') // Find the child "media:rating" element.
        .map((e) =>
            Rating.parse(e)) // Convert the child element to a Rating object.
        .firstOrNull, // Get the first Rating object or null if not found.
    thumbnail: element
        .findElements(
            'media:thumbnail') // Find the child "media:thumbnail" element.
        .map((e) => Thumbnail.parse(
            e)) // Convert the child element to a Thumbnail object.
        .firstOrNull, // Get the first Thumbnail object or null if not found.
    title: element
        .findElements('media:title') // Find the child "media:title" element.
        .map((e) =>
            Title.parse(e)) // Convert the child element to a Title object.
        .firstOrNull, // Get the first Title object or null if not found.
    description: element
        .findElements(
            'media:description') // Find the child "media:description" element.
        .map((e) => Description.parse(
            e)) // Convert the child element to a Description object.
        .firstOrNull, // Get the first Description object or null if not found.
  );
}