-
Notifications
You must be signed in to change notification settings - Fork 29.1k
Description
Use case
For the new Preview api, it would be very useful to be able to see a matrix (or group) of different resolutions for a single widget, similar to DeviceBuilder
in golden_toolkit and @Preview
Multi-preview Templates in Jetpack Compose.
Here is a POC using current Preview api (3.35.1):

Proposal
In #166447 MultiPreview
was added. GroupDevicePreview
could extend this class, with an api similar to Preview
:
final String? baseName;
final double? maxSize;
final List<PreviewDevice>? devices;
final double? textScaleFactor;
final WidgetWrapper? wrapper;
final PreviewTheme? theme;
final Brightness? brightness;
final PreviewLocalizations? localizations;
and would create devices.length
previews (as seen in POC above).
PreviewDevice
could be abstract class which users can extend, with a couple of defaults built in (i.e. PhonePortraitPreviewDevice). This class could contain name
, size
which GroupDevicePreview
would use along with baseName
, maxSize
to determine name
, size
for the individual Preview
s.
I believe there is more value in having this as part of Flutter itself instead of a third-part package, similar Composable Multi-preview Templates mentioned above.