flutter/examples
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
..
api [ Widget Preview ] Add support for theme and brightness properties on Preview (#167001) 2025-04-15 17:51:40 +00:00
flutter_view Convert AppLinkSettings to kotlin (#164391) 2025-03-11 17:00:17 +00:00
hello_world [ Widget Preview ] Add support for theme and brightness properties on Preview (#167001) 2025-04-15 17:51:40 +00:00
image_list Convert AppLinkSettings to kotlin (#164391) 2025-03-11 17:00:17 +00:00
layers Remove redundant useMaterial3: true (#163376) 2025-03-14 17:50:20 +00:00
platform_channel [ Widget Preview ] Add support for theme and brightness properties on Preview (#167001) 2025-04-15 17:51:40 +00:00
platform_channel_swift [ Widget Preview ] Add support for theme and brightness properties on Preview (#167001) 2025-04-15 17:51:40 +00:00
platform_view Convert AppLinkSettings to kotlin (#164391) 2025-03-11 17:00:17 +00:00
splash Roll pub packages (#163083) 2025-02-11 23:47:59 +00:00
texture [ Widget Preview ] Add support for theme and brightness properties on Preview (#167001) 2025-04-15 17:51:40 +00:00
.clang-format Implement Linux part of examples (#108068) 2022-12-08 08:44:11 +13:00
flutter_gallery.readme Move flutter_gallery to the testing folder (#52532) 2020-03-16 10:31:42 +01:00
README.md Update flutter.dev links from misc packages to more permanent destinations (#150532) 2024-06-20 23:09:08 +00:00

Flutter Examples

This directory contains several examples of using Flutter. To run an example, use flutter run inside that example's directory. See the getting started guide to install the flutter tool.

For additional samples, see the flutter/samples repo.

Available examples include:

Notes

Note on Gradle wrapper files in .gitignore:

Gradle wrapper files should normally be checked into source control. The example projects don't do that to avoid having several copies of the wrapper binary in the Flutter repo. Instead, the Gradle wrapper is injected by Flutter tooling, and the wrapper files are .gitignore'd to avoid making the Flutter repository dirty as a side effect of running the examples.