getPropsToForward method

Map getPropsToForward({
  1. Set<Type>? exclude,
  2. bool domOnly = false,
})

Returns a copy of this instance's props excluding the keys found in exclude.

exclude should be a Set of PropsMixin Types. If exclude is not set, it defaults to using the current instance's Type.

Example:

Component with a single props mixin:

mixin FooPropsMixin on UiProps {
  String foo;
}

UiFactory<FooPropsMixin> Foo = uiFunction((props) {
  return (Bar()
    // Filter out props declared in FooPropsMixin
    // (used as the default for `exclude` since that's what `props` is statically typed as)
    // when forwarding to Bar.
    ..addAll(props.getPropsToForward())
  )();
});

Component with a more than one props mixin:

mixin FooPropsMixin on UiProps {
  String foo;
}
class FooProps = UiProps with BarProps, FooPropsMixin;

UiFactory<FooProps> Foo = uiFunction((props) {
  return (Bar()
    // Filter out props declared in FooPropsMixin when forwarding to Bar.
    ..addAll(props.getPropsToForward(exclude: {FooPropsMixin}))
  )();
});

To only add DOM props, use the domOnly named argument.

Related: UiComponent2's addUnconsumedProps

Implementation

Map getPropsToForward({Set<Type>? exclude, bool domOnly = false}) {
  return _propsToForward(exclude: exclude, domOnly: domOnly, propsToUpdate: {});
}