1

The freezed docs mention being able to define shared properties for union types, but the examples given show all of the properties being redefined for each type. Is there an easy way to only have to define all of the common properties just once?

anqit
  • 780
  • 3
  • 12
  • If the same params are repeated in all the union types, then it is best to wrap those params inside a class and pass the singe param for each union types. – BHARATH T Oct 20 '22 at 05:52
  • I see. Is a mixin or interface not a possibility? – anqit Oct 23 '22 at 04:12
  • 2
    Not simple to answer. Checkout the difference between composition and aggregation and then determine which one is best for your need https://www.geeksforgeeks.org/difference-between-aggregation-and-composition-in-java/. Btw using interface or mixin is very simple. Just follow https://pub.dev/packages/freezed#mixins-and-interfaces-for-individual-classes-for-union-types – BHARATH T Oct 23 '22 at 06:30

0 Answers0