搜尋分類、套件與程式碼儲存庫

套件詳情v0.3.4

simulator

一個(不只)是裝置模擬器的Flutter。讓建立多平台UI變得輕鬆簡單

近 30 天下載
180
喜歡數
31
Pub 分數
60

安裝套件

flutter pub add simulator

套件介紹

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

模擬器是適用於Flutter的多功能工具,不僅超越基本設備模擬,還能讓開發者輕鬆測試與預覽跨平台使用者介面。它提供直覺的方式來視覺化應用程式在各種裝置與螢幕尺寸上的外觀,簡化UI開發流程。支援螢幕擷取與截圖功能,進一步提升設計與測試工作流程。設計用於無縫整合,有助於確保跨平台的一致體驗,且無需實體裝置。

適用情境

  • 測試響應式佈局
  • 預覽應用在多個設備上的外觀
  • 截取螢幕截圖以用於文件
  • 驗證跨平台 UI 一致性
  • 簡化UI設計審查
  • 加速開發週期

主要特色

  • 多裝置模擬
  • 即時螢幕預覽
  • 內建截圖擷取
  • 跨平台 UI 驗證
  • 輕鬆整合至Flutter專案
  • 對不同螢幕密度的支援

適合對象

  • Flutter 開發人員建構響應式 UI
  • 專注於一致的跨平台設計
  • 設計師與開發人員協作
  • 需要頻繁進行UI測試的專案

使用建議

  • 不取代實體裝置測試
  • 僅限UI模擬,不包含完整應用行為
  • 可能需要額外設定才能使用進階功能
  • 不適用於生產部署

原始 README

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

simulator

Pub Publisher Pub Version

Warning: This is a work in progress and may contain bugs. Use at your own risk.

A device simulator for Flutter. Run your app on the desktop, and simulate a device of your choice. Perfect for rapid development of multi-platform user interfaces.

Image 1     Image 2

Why?

In my experience, developing a multi-platform app is a pain. You have to constantly switch between devices to see how your app looks and behaves. This is especially true for mobile gestures and keyboard input. This package aims to solve this problem by providing a way to simulate a device on the desktop. It's not perfect, but it's a start. I personally find that I'm much more productive when using this package.

Another benefit is that building and hot-refreshing the app is much faster on the desktop. This is especially true for complex UIs.

However, this package is not a replacement for testing on real devices. It's just a tool to make development easier.

Features

  • Simulate your app on a bunch of Android and iOS devices (list below).
  • Pixel-perfect screenshotting of the simulated device. Great for creating marketing images.
  • Simulate the device keyboard.
  • Synthesize mobile gestures (tap, drag, pinch, etc.) with a mouse.
  • Quickly enable various Flutter debug flags.
  • Complete MediaQuery and system locale control.
  • Ability to add custom modules.

In progress:

  • Device rotations (works, but is buggy).
  • Video recording of the simulated device.
  • Make it easier to intercept system calls.
  • Improve the locale module.

Supported devices

  • iPhone 15
  • iPhone 15 Plus
  • iPhone 15 Pro
  • iPhone 15 Pro Max
  • iPhone SE (gen 3)
  • Pixel phones (from 2 to 7, with a and XL variants)

Usage

  1. Add the package to your pubspec.yaml:
dependencies:
  simulator: ^0.3.2

Note: this package only works in Debug mode. The entire code of the package should be tree-shaken away in Release mode.

  1. Create an entrypoint for the simulator. It should be a separate file from your main entrypoint. For example, main.simulator.dart:
import 'package:simulator/simulator.dart';

void main() {
  runSimulatorApp(MyApp());
}

Note: if you have code that uses FlutterWidgetsBinding.ensureInitialized(), you should replace it with SimulatorFlutterWidgetsBinding.ensureInitialized(). This makes sure that the simulator initializes its bindings.

Now you can run the simulator with flutter run -t lib/main.simulator.dart. Make sure that the simulator is ran for the desktop platform.

macOS

The minimum macOS deployment target is 10.15.0.

See https://github.com/macosui/macos_window_utils.dart?tab=readme-ov-file#getting-started for more information on how to change the minimum deployment target.

Built-in modules

Screenshot module

Allows you to take a screenshot of the simulated device (or just the app). By default, the screenshots are saved to the temporary directory.

Screenshot module

Device module

Allows you to pick a device to simulate. The device is picked from a list of supported devices.

Device module

Keyboard module

Allows you to simulate the device keyboard. When the system call to show the keyboard is intercepted, the keyboard is shown in the simulator instead. You can choose between no keyboard, an iOS or an Android keyboard (or auto-detect based on the platform).

Keyboard module

Gestures module

Allows you to simulate mobile gestures with a mouse. The main feature is the conversion of mouse events to touch gestures in the simulator view. You can also simulate a zoom gesture by enabling it and holding the Ctrl key.

Gestures module

VM module

Shows the heap usage for all of the isolates in the VM. It also allows you to fire the memory pressure event (didHaveMemoryPressure()).

VM module

Debug module

Allows you to enable various Flutter debug flags. You can enable the performance overlay, the debug banner, the repaint rainbow, and the slow animations.

Additionally, includes some custom debugging flags:

  • Pointer area highlight - highlights and shows the size of the pointer area of GestureDetector widgets when hovered.

  • Visualize view paddings - shows the view paddings and insets applied to the app.

Debug module

Locale module

Allows you to control the system locale. This is work-in-progress and will be improved.

Locale module

MediaQuery module

Allows you to set the MediaQuery properties for the app. This is transparent to the app and appears like host device properties.

MediaQuery module

Custom modules

More documentation soon. If curious, check the lib/src/modules directory.

Contacts

For any questions, feel free to contact me at:

  • kk.erzhan@gmail.com

所屬分類

依賴

原始碼儲存庫

使用此套件的專案

暫無相關資料。