How to Create a Flexible Custom Wrapper for Widgets to overriding some default properties? #147718
Labels
in triage
Presently being triaged by the triage team
waiting for customer response
The Flutter team cannot make further progress on this issue until the original reporter responds
I'm currently developing a custom wrapper for widgets in Flutter that enables extensive customization, similar to how
{...rest}
works in TypeScript with React components. However, Dart doesn't support the spread operator for widget properties, so I'm struggling to find an effective way to forward a wide range of properties to a base widget likeIconButton
.Here's an example of what I might do in TypeScript:
In Flutter, I'm looking for a way to achieve something similar. How can I create a wrapper that allows users to customize any widget with multiple properties without manually specifying each one? Here's a basic approach in Dart, but it requires explicitly forwarding each property, which isn't scalable. For example, an
IconButton
can have additional properties like activecolor and border. Manually copying all of them can make the code redundant. Here's my current approach:How can I achieve similar behavior to React Native in Flutter? Any insights would be greatly appreciated!
I try to use extend and extension , but they all looks like required you copy all the properties.
The text was updated successfully, but these errors were encountered: