Component.fragment constructor

const Component.fragment(
  1. List<Component> children, {
  2. Key? key,
})

Creates a component which renders a list of child components without any wrapping element.

This is useful when you want to return multiple elements from a build method without adding an extra wrapping element to the html DOM.

Example:

return Component.fragment([
  Component.element(tag: 'span', children: []),
  Component.element(tag: 'button', children: []),
]);

Renders:

<span></span>
<button></button>

Implementation

const factory Component.fragment(List<Component> children, {Key? key}) = Fragment._;