Children

Utilities for dealing with the children prop.

React.Children provides utilities for dealing with the opaque data structure of props.children.

Example:

final MyComponent = registerFunctionComponent((props) {
  final children = props['children'];
  final count = Children.count(children);
  return div(children: [
    pEl('This component has $count children'),
    ...Children.toArray(children),
  ]);
});

Properties

hashCode → int
The hash code for this object.
no setterinherited

runtimeType → Type

A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited

toString() → String

A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

count(JSAny? children) → int
Returns the total number of children.

forEach(JSAny? children, void fn(ReactElement child, int index)) → void

Iterates over children, calling fn for each child.

map(JSAny? children, ReactElement fn(ReactElement child, int index)) → List<ReactElement>?

Calls a function for each child in children.

only(JSAny? children) → ReactElement

Verifies that children has only one child and returns it.

toArray(JSAny? children) → List<ReactElement>

Returns children as a flat array.