apply method

  1. @override
Widget apply(
  1. BuildContext context,
  2. Widget child
)
override

Wraps the child widget in the full layrz_ui theme context.

Applies the same nesting layers as the nesting LayrzApp installs at the root (minus app-level concerns like ScrollConfiguration and custom builder callbacks):

  1. LayrzTheme — propagates the theme data to all descendants
  2. DefaultTextStyle — installs the base text style
  3. IconTheme — configures icon sizing and colour
  4. ColoredBox — paints the background colour

This ensures that previewed widgets have access to LayrzTheme.of and the tokens extension method, and that colours, typography, and icon rendering all match the production app.

Implementation

@override
Widget apply(BuildContext context, Widget child) {
  return LayrzTheme(
    data: data,
    child: DefaultTextStyle(
      style: data.textStyle,
      child: IconTheme(
        data: data.iconTheme,
        child: ColoredBox(
          color: data.backgroundColor,
          child: child,
        ),
      ),
    ),
  );
}