LayrzPreviewTheme class final
A PreviewThemeData implementation that applies the layrz_ui light-mode theme to Flutter 3.47+ widget previews.
This class extends the SDK's PreviewThemeData (an abstract base class) to provide
a complete light-theme context for @Preview annotations. It reproduces the exact
widget nesting that LayrzApp installs at the root, so previewed widgets render
identically to the production app rather than with SDK defaults.
To use with @Preview annotations, use the top-level function layrzPreviewLightTheme
(not the static method LayrzPreviewTheme.light, which the code generator cannot resolve):
import 'package:flutter/widget_previews.dart';
import 'package:layrz_ui/preview.dart';
@Preview(
name: 'Light',
theme: layrzPreviewLightTheme,
)
Widget previewMyWidget() => MyWidget(/* ... */);
The apply method nests the child in the exact same layers as the nesting LayrzApp installs at the root:
- LayrzTheme to propagate theme data
- DefaultTextStyle to set base typography
- IconTheme to configure icon styling
- ColoredBox to paint the background
The theme's data can be accessed via LayrzTheme.of or the tokens extension
method inside any descendant.
- Inheritance
-
- Object
- PreviewThemeData
- LayrzPreviewTheme
Constructors
- LayrzPreviewTheme({required LayrzThemeData data})
-
Creates a LayrzPreviewTheme wrapping the given LayrzThemeData.
const
Properties
- data → LayrzThemeData
-
The theme data applied to all descendants in apply.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
apply(
BuildContext context, Widget child) → Widget -
Wraps the child widget in the full layrz_ui theme context.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
light(
) → PreviewThemeData - Creates a LayrzPreviewTheme with default light-mode design tokens.