transform method

  1. @override
Preview transform()
override

Applies a transformation to the current Preview.

Overriding this method allows for custom Preview implementations to initialize more complicated previews that would not otherwise be possible due to restrictions around constant constructors used for annotations.

See also:

Implementation

@override
Preview transform() {
  final original = super.transform();
  final builder = original.toBuilder();
  builder.wrapper = (child) {
    return ShadcnLayer(
      theme: brightness == Brightness.dark
          ? ThemeData.dark(
              colorScheme: colorScheme ?? ColorSchemes.darkSlate,
            )
          : ThemeData(colorScheme: colorScheme ?? ColorSchemes.lightSlate),
      child: original.wrapper?.call(child) ?? child,
    );
  };
  return builder.build();
}