搜尋套件、儲存庫與 APP 分類

套件詳情v2.9.9

device_preview_plus

大致預覽您的 Flutter 應用在另一台設備上的外觀和效能

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1.4萬
喜歡數
75
Pub 分數
150

安裝套件

flutter pub add device_preview_plus

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Device Preview Plus 允許開發者在開發環境中直接模擬其 Flutter 應用在不同設備上的外觀與行為。它提供精確的設備特定渲染,包括螢幕尺寸、方向以及平台特定的 UI 行為。該套件支援多個平台——Android、iOS、Web、macOS、Windows 和 Linux——非常適合跨平台測試。透過即時預覽調整與可自訂的設備設定檔,它能無需實體設備即可簡化 UI 驗證。

適用情境

  • 在設備上測試響應式佈局
  • 在各種螢幕尺寸上驗證UI一致性
  • 在開發過程中模擬設備特定行為
  • 快速在設備設定檔之間切換
  • 預覽應用程式外觀在不同作業系統上

主要特色

  • 即時設備模擬
  • 支援所有主要平台
  • 可自訂的裝置設定檔
  • 方向與縮放調整
  • 與 Flutter 開發工具的整合
  • 跨平台 UI 測試

適合對象

  • Flutter 開發者建構跨平台應用
  • 需要快速UI驗證的團隊
  • 設計師與開發人員協作
  • 需要一致設備預覽的專案

使用建議

  • 可能影響大型專案中的效能
  • 需要手動設定自訂裝置
  • 僅限視覺模擬(非完整執行時測試)
  • 不可替代實體裝置測試
  • 最佳使用時機為開發期間,而非生產環境

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Device Preview for Flutter

pub package docs MIT License GitHub Actions Codacy Badge style: flutter_lints

Github-sponsors BuyMeACoffee Ko-Fi LiberaPay Patreon PayPal

This is a fork of device_preview to keep it up to date with newer Flutter versions.

For users migrating from the device_preview package the only changes required are changing your pubspec.yaml file to point to device_preview_plus and changing any import statements to point to the updated package:device_preview_plus\device_preview_plus.dart.

Device Preview for Flutter

Approximate how your app looks and performs on another device. Main features:

  • 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

Getting Started

Add this to your project's pubspec.yaml file:

dependencies:
  device_preview_plus: ^2.9.4

Usage

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).

Make sure to override the previous properties as described. If not defined, MediaQuery won't be simulated for the selected device.

import 'package:device_preview_plus/device_preview_plus.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(),
    );
  }
}

Demo

Open the demo

Limitations

Think of Device Preview as a first-order approximation of how your app looks and feels on a mobile device. With Device Mode you don't actually run your code on a mobile device. You simulate the mobile user experience from your laptop, desktop or tablet.

There are some aspects of mobile devices that Device Preview will never be able to simulate. When in doubt, your best bet is to actually run your app on a real device.

所屬分類

依賴

依賴清單 7 項

原始碼儲存庫

使用此套件的專案