mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This change updates `Preview` to be a `base` class instead of `final`, allowing for developers to extend `Preview` and create their own custom preview annotations. To reduce friction associated with working with `const` constructors, two new methods have been added: `MultiPreview.transform()` and `Preview.transform()`. These methods are invoked at runtime by the preview environment, allowing for developers to create or modify `Preview` instances with non-constant values. This also relaxes restrictions around `Preview`'s callback parameters (e.g., `wrapper`), which do not need to be static or public when provided to a `Preview` in the context of a `*.transform()` method. This makes it possible to create custom preview classes that completely encapsulate their callbacks, removing the need for separate public, static function declarations. To make transforming `Preview`s simpler, a `PreviewBuilder` utility class has also been added. Fixes https://github.com/flutter/flutter/issues/175534