Parent builder only has a limited set of predefined widgets, sometimes you want to go beyond that or using a custom widget with Niku.

With builder() you can wrap any widget as a parent using Parent Builder.

  ..size(100, 100)
  ..builder((child) => CustomWidget(child: child))

Just like any builder method, the builder takes Function with a child as a parameter, returning the current instance of the widget and return your custom widget as need.


You can create a function that returns any widget and reuse it anywhere just like apply().

final card = (Widget child) => CustomCard(child: child)

  ..size(100, 100)


Or creating a factory function to providing a property.

final card = ({ 
  double width,
}) => (Widget child) 
    => CustomCard(child: child, width);

  ..size(100, 100)

Now you can compose any 3rd widget or create custom parent builder property and seamlessly apply it to Niku.