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

device_frame 封面
套件詳情v1.4.0

device_frame

常見裝置的模擬圖。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
30.1萬
喜歡數
165
Pub 分數
140

安裝套件

flutter pub add device_frame

套件介紹

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

device_frame 套件提供可自訂的常見裝置模擬外框,讓開發者能在真實的裝置情境中預覽其 Flutter 應用程式。它支援多種平台,包括 Android、iOS、Web、macOS、Windows 與 Linux。適用於簡報、文件編寫與設計審查,可輕鬆整合至應用程式或開發工作流程中。該套件提供預設的裝置外框,支援可調整的螢幕尺寸與方向,無需外部工具即可提升視覺溝通效果。

適用情境

  • 文件中的應用預覽
  • 設計演示原型
  • 使用設備上下文進行UI測試
  • 開發者示範
  • 開發過程中的視覺反饋

主要特色

  • 預定義設備範本
  • 跨平台支援
  • 可自訂的框架尺寸
  • 與 Flutter 的輕鬆整合
  • 支援多種螢幕方向

適合對象

  • Flutter 開發者
  • UI/UX 設計師
  • 技術撰寫者
  • 產品經理
  • 簡報創作者

使用建議

  • 不適用於生產應用UI
  • 新設備需要手動更新幀
  • 僅限靜態原型渲染
  • 無互動設備行為
  • 最佳用於開發或示範環境

原始 README

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

Device Preview for Flutter

Simulate any device — screen, safe areas, locale, accessibility — with full framework fidelity.

You build on one screen; your users arrive on hundreds. Device Preview switches your running app to another device — an old 320pt phone, a tablet in landscape, a notched display, a half-width desktop window — instantly, with no rebuild and no simulator.

Screen size, pixel ratio, safe areas, orientation, folds, the software keyboard, locales, brightness, text scale, accessibility settings and target platform all change with it, and your app reads them through the same MediaQuery it always used. So the problems that normally surface in front of a customer — a clipped headline, a button under the home indicator, an overflow at 200% text — surface in front of you instead.

Control it from Flutter DevTools, from Dart, or from your tests.

Quickstart

dependencies:
  device_preview: <latest version>
void main() {
  DevicePreview.enable();
  runApp(const MyApp()); // runs as usual — now simulatable
}

That's the whole integration. Open DevTools, select the device_preview tab, and pick a device.

enable() is safe to call unconditionally: simulation is active in debug and profile builds and completely off in release, so nothing ships to your users. Pass a value to decide yourself — DevicePreview.enable(enabled: kDebugMode) for debug only, DevicePreview.enable(enabled: false) to turn it off.

Programmatic control:

import 'package:device_preview/presets.dart';

final c = DevicePreview.controller;
await c.applyPreset(DevicePresets.iPhone16Pro);
await c.setOrientation(Orientation.landscape);
await c.update((s) => s.copyWith(textScaleFactor: 2.0, platformBrightness: Brightness.dark));
await c.reset();

DevicePreview.controller throws when simulation is off (every release build); use DevicePreview.maybeController?.… from code that ships.

See device_preview/README.md for the full package documentation, including widget-test support via DevicePreviewBindingMixin.

Documentation

Open the website · Design document

Repository structure

Directory Contents
device_preview The published package: binding, controller, presets, service extensions, bundled DevTools extension build.
device_preview_devtools_extension Source of the DevTools extension web app (never published; built into device_preview/extension/devtools/build).
device_specs The device catalog: one JSON per device — metrics, screen outline and body artwork. Generated into both the extension catalog and the package's built-in DevicePresets; see its README to add a device.
device_frame Legacy device frame drawings package from the 2.x era. Nothing in the 3.0 release depends on it — 3.0 renders frames from the device_specs artwork, carried by the built-in presets and pushed over the DevTools protocol.
docs The website, including its interactive demo — docs/demo is the counter example built for the web, docs/device_catalog.json the catalog its HTML panel pushes to it. Rebuild both with tool/build_demo.sh.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案