2 Commits

Author SHA1 Message Date
Ben Konyi
024a80bf42
[ Widget Preview ] Cleanup for experimental release (#173289)
Widget previews are being released as an experimental feature in the
next stable release.

This change has some minor last minute changes to prepare for release:
  - Makes `flutter widget-preview` visible
  - Adds documentation links to docs.flutter.dev (not yet staged)
- Fixes minor bug with asset loading due to `AssetManifest.bin.json` not
being accounted for in the asset path mapping logic
2025-08-05 18:10:06 +00:00
Ben Konyi
3595e7dad0
[ Widget Preview ] Add support for theme and brightness properties on Preview (#167001)
The `theme` parameter of `Preview(...)` allows for developers to provide
a callback that returns a `PreviewThemeData` instance which can contain
theming data for Material and Cupertino widgets in both light and dark
modes. The provided theme data will be injected into the widget tree and
applied to the previewed widget.

The `brightness` parameter allows for developers to specify an initial
brightness setting (e.g., light vs dark mode) for the previewed widget.
If not provided, the current system default is used.

A new button has also been added to each widget preview card that allows
for toggling between light and dark mode for individual previews.

**Demo:**


https://github.com/user-attachments/assets/f0a4a3bc-25d2-49b0-a5f6-9149eccfc1d4

Fixes https://github.com/flutter/flutter/issues/166436
Fixes https://github.com/flutter/flutter/issues/166275
Fixes https://github.com/flutter/flutter/issues/166279
Fixes https://github.com/flutter/flutter/issues/166437
2025-04-15 17:51:40 +00:00