toArray
List<
Returns children as a flat array.
Useful when you need to manipulate the children with standard array methods like filter, sort, or reverse.
Example:
final childArray = Children.toArray(props['children']);
final reversed = childArray.reversed.toList();
Implementation
static List<ReactElement> toArray(JSAny? children) =>
_childrenToArray(children).toDart
.map(
(e) => switch (e) {
final JSObject o => ReactElement.fromJS(o),
_ => throw StateError('Invalid child element'),
},
)
.toList();