addPropsToForward method
A utility function to be used with modifyProps
to add props excluding the keys found in exclude
.
exclude
should be a Set
of PropsMixin Type
s.
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.
..modifyProps(props.addPropsToForward())
)();
});
Component with a more than one props mixin:
mixin FooPropsMixin on UiProps {
String foo;
}
class FooProps = UiProps with BarProps, FooPropsMixin;
UiFactory<FooProp> Foo = uiFunction((props) {
return (Bar()
// Filter out props declared in FooPropsMixin when forwarding to Bar.
..modifyProps(props.addPropsToForward(exclude: {FooPropsMixin}))
)();
});
To only add DOM props, use the domOnly
named argument.
Related: UiComponent2
's addUnconsumedProps
Implementation
PropsModifier addPropsToForward({Set<Type>? exclude, bool domOnly = false}) {
return (Map<dynamic, dynamic> props) {
_propsToForward(exclude: exclude, domOnly: domOnly, propsToUpdate: props);
};
}