Approximate how your app looks and performs on another device.
-
Preview any device from any device
-
Change the device orientation
-
Dynamic system configuration (language, dark mode, text scaling factor, ...)
-
Freeform device with adjustable resolution and safe areas
-
Keep the application state
-
Plugin system (Screenshot, File explorer, ...)
-
Customizable plugins
Since Device Preview is a simple Dart package, you have to declare it as any other dependency in your pubspec.yaml file.
dependencies:
device_preview: <latest version>
Wrap your app's root widget in a DevicePreview and make sure to :
-
Set your app's useInheritedMediaQuery to true.
-
Set your app's builder to DevicePreview.appBuilder.
-
Set your app's locale to DevicePreview.locale(context).
import 'package:device_preview/device_preview.dart'; void main() => runApp( DevicePreview( enabled: !kReleaseMode, builder: (context) => MyApp(), // Wrap your app ), ); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( useInheritedMediaQuery: true, locale: DevicePreview.locale(context), builder: DevicePreview.appBuilder, theme: ThemeData.light(), darkTheme: ThemeData.dark(), home: const HomePage(), ); } }