flutter_device_preview
flutter_device_preview copied to clipboard
Device Preview as a target platform
I'm currently thinking about defining Device Preview as a target platform instead of an embedded widget. This would basically launch the app as an inner view.
Concept
Instead of compiling the application as a macOS (or Windows), it would launch it as an embedded view in a macOS Device Preview application.
Ideally, this Device Preview shell app would be developed with Flutter to make it cross platform!
Advantages
No configuration needed for users, just choosing Device Preview as a target platform.
This would also simplify a lot of device preview implementation by implementing the platform elements instead of relying only on MediaQuery.
It would also allow simulating system events, and even overriding plugins to create simulations (push, ...).
The problem
I have absolutely no idea how to achieve that. I know that I would have to create a fork of Flutter engine and tweak the default macos/windows targets to embed the application.
There is this bug https://github.com/flutter/flutter/issues/65067 talking about custom devices. That could also help your idea.
Not quiet this, but I recently did a different entry point and wrote some plugins which I can use to load in pages on the fly with mocks. Might potentially be nice to add some docs as making another entry point for simulation and calling via -d lib\main_simulate.dart
for example is a good quick win for some teams.