パッケージ、リポジトリ、アプリカテゴリを検索

media_query_preview のカバー
パッケージ詳細v0.1.0

media_query_preview

このパッケージは、カスタムデバイス、明るさ、テキストスケールをサポートし、さまざまなデバイスおよび状態でのUIプレビューを可能にします。開発向けであり、本番環境には適していません。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
14
いいね数
3
Pub ポイント
140

パッケージをインストール

flutter pub add media_query_preview

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

MediaQueryPreview は、さまざまなデバイス、画面サイズ、明るさレベル、テキスト拡大率でリアルタイムの UI プレビューを可能にする開発ツールです。物理的なデバイスにデプロイせずに、アプリがさまざまな設定でどのように表示されるかを視覚的に確認できます。このパッケージはカスタムデバイス定義をサポートしており、開発ワークフロー専用に設計されており、本番環境での使用は想定していません。Flutter の MediaQuery とシームレスに統合され、デザインおよびテストフェーズでの迅速な反復が可能です。

用途

  • レスポンシブレイアウトのテスト
  • 異なるデバイス画面のシミュレーション
  • アクセシビリティ設定の調整
  • さまざまな条件下でのUI動作の検証
  • UI開発ワークフローの最適化

主な機能

  • カスタムデバイス設定をサポートしています
  • 画面サイズ変更のリアルタイムプレビュー
  • 明るさとテキストスケールの調整
  • クロスプラットフォーム互換性
  • 既存のFlutterプロジェクトとの簡単な統合

適している対象

  • デザイン段階のFlutter開発者
  • 応答性のあるUIに注力するチーム
  • アクセシビリティテスト
  • 迅速なプロトタイピング

注意事項

  • 本番環境での使用を想定していません
  • カスタムデバイス用に手動設定が必要
  • 開発環境に限定
  • 過度使用時にパフォーマンスに影響を与える可能性があります
  • 実機テストを代替しません

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

pub package GitHub deployments

Have you ever experienced your UI breaking when the font size is too large or the screen size of the device is small? Checking for these issues can be a hassle.

This package allows you to preview how your implemented UI will appear on various devices with different screen sizes, text scales, and brightness.

It was inspired by device_preview.

Media Query Preview

Features

This package provides the following features:

  • Preview your UI on various devices with different screen sizes, text scales, and brightness.
  • In addition to pre-defined devices like PreviewDevice.iPhone5_5inch and PreviewDevice.android6_7inch, you can create custom PreviewDevice instances.
  • Preview your UI when the keyboard is displayed.
  • Manipulate each preview individually.
  • Friendly with riverpod.

Demo

Check out the demo at https://kingu-dev.github.io/media_query_preview.

Usage

If you are using riverpod, you can do the following.

// Initialize Provider
final container = ProviderContainer();

final previewDevices = [
  [
    PreviewDevice.iPhone5_5inch(
      textScaleFactor: 0.5,
    ),
    PreviewDevice.iPhone5_5inch(),
    PreviewDevice.iPhone5_5inch(
      brightness: Brightness.dark,
    ),
    PreviewDevice.iPhone5_5inch(
      textScaleFactor: 1.5,
    ),
  ],
  [
    PreviewDevice.iPhone6_7inch(
      textScaleFactor: 0.5,
    ),
    PreviewDevice.iPhone6_7inch(),
    PreviewDevice.iPhone6_7inch(
      brightness: Brightness.dark,
    ),
    PreviewDevice.iPhone6_7inch(
      textScaleFactor: 1.5,
    ),
  ],
  [
    PreviewDevice.android6_7inch(
      textScaleFactor: 0.5,
    ),
    PreviewDevice.android6_7inch(),
    PreviewDevice.android6_7inch(
      brightness: Brightness.dark,
    ),
    PreviewDevice.android6_7inch(
      textScaleFactor: 1.5,
    ),
  ]
];

runApp(
  MediaQueryPreview(
    previewDevices: previewDevices,
    builder: (_, previewDevice) {
      // If you want to change the theme based on the targetPlatform,
      // you can get the targetPlatform from [previewDevice.targetPlatform].
      return UncontrolledProviderScope(
        container: container,
        child: const MyApp(),
      );
    },
  ),
);

If you are not using riverpod, it is even simpler.

runApp(
  MediaQueryPreview(
    previewDevices: previewDevices,
    builder: (_, previewDevice) {
      // If you want to change the theme based on the targetPlatform,
      // you can get the targetPlatform from [previewDevice.targetPlatform].
      return const MyApp();
    },
  ),
);

Attention

  • It is recommended to use this package only development. Please do not use it in production.
  • This package allows you to display multiple instances of the Widget you implemented at the same time, which may lead to poor performance or issues with state management.
  • If you manage GlobalKey with global variables, they will be shared across each preview, which can lead to errors or unintended behavior. Since the widget trees of each preview are independent, it is recommended to generate a separate GlobalKey for each tree.

Future

If you have Apple Vision Pro, you can use it as a "Designed for iPad" app. This is the future!

Vision Pro

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。