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

debug_overlay のカバー
パッケージ詳細v2.0.0

debug_overlay

アプリの中央オーバーレイを介してデバッグ情報を表示し、設定を変更します。

AndroidiOS
30日間ダウンロード
767
いいね数
28
Pub ポイント
160

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

flutter pub add debug_overlay

パッケージ概要

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

debug_overlay パッケージは、Flutter アプリにおいて開発中にデバッグ情報を表示し、設定を動的に調整するための中央的なオーバーレイを提供します。開発者はアプリのリアルタイムメトリクスを確認したり、機能を切り替えたり、アプリの再起動なしに状態を確認できます。オーバーレイは簡単なジェスチャーでアクセスでき、Android および iOS ビルドにシームレスに統合されます。使いやすさを重視して設計されており、アプリインターフェース内で診断データや設定可能なオプションにすばやくアクセスできるため、デバッグワークフローを強化します。

用途

  • 開発中のリアルタイムデバッグ
  • リアルタイムでアプリ機能を切り替え
  • アプリケーションパフォーマンスメトリクスの監視
  • 状態の変更を確認する
  • さまざまな構成のテスト
  • デバッグツールへの迅速なアクセス

主な機能

  • 集中型デバッグオーバーレイ
  • ジェスチャーによるアクティベーション
  • ライブ設定の調整
  • Android および iOS のプラットフォーム対応
  • pub add を用いた最小限のセットアップ
  • 実行時アプリ情報の表示

適している対象

  • アクティブな開発中のFlutter開発者
  • 迅速なデバッグが必要なチーム
  • 動的機能トグルを必要とするアプリ
  • プロトタイピングおよびテストフェーズ
  • 開発者はデバッグ中にUXに注力しています

注意事項

  • 本番環境での使用を想定していません
  • テスト中にオーバーレイがUIに影響を与える可能性があります
  • リリース前に手動で削除が必要です
  • 制限されたカスタマイズオプション
  • センシティブなデバッグデータに対する組み込みのセキュリティなし
  • 大規模なアプリではパフォーマンスにわずかな影響を与える可能性があります

元の README

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

debug_overlay

🐛 View debug infos and change settings via a central overlay for your app.

debug_overlay demo

To add a debug overlay to your app, pass DebugOverlay.builder() to MaterialApp/CupertinoApp/WidgetsApp.builder:

MaterialApp(
  builder: DebugOverlay.builder(),
  // And other customization...
)

The debug overlay only works in debug mode and is not included in your widget tree in profile or release mode unless you pass enableOnlyInDebugMode: false.

To open the overlay, call DebugOverlay.show().

By default, this overlay includes MediaQueryDebugHelper, PackageInfoDebugHelper, and DeviceInfoDebugHelper.

Debug Helpers

To add a debug helper, you have to register it by calling either of the following two (which accept any sliver widget):

  • DebugOverlay.prependHelper(myDebugHelper) to add it to the front of the list
  • DebugOverlay.appendHelper(myDebugHelper) to add it to the end of the list

Or, if you want to override all currently registered overlays, set DebugOverlay.helpers.value to a list of sliver widget.

DeviceInfoDebugHelper
DeviceInfoDebugHelper demo

Displays information obtained from device_info_plus.

MediaQueryDebugHelper
´MediaQueryDebugHelper demo

Displays information obtained from MediaQuery.

LogsDebugHelper
´LogsDebugHelper demo

Displays logs generated by your app. To use it, follow these steps:

  1. Store its mutable state, e.g., in a global variable:

    final logs = LogCollection(
      // Default values:
      maximumSize: 500,
      onlyStoreLogsInDebugMode: true,
    );
    
  2. Register the helper and supply its state, e.g., in main():

    void main() {
      if (kDebugMode) {
        DebugOverlay.appendHelper(LogsDebugHelper(logs));
      }
    
      runApp(MyApp());
    }
    
  3. When you generate logs, add them to the collection. Except for message, all parameters are optional:

    logs.add(Log(
      level: DiagnosticLevel.info,
      timestamp: DateTime.now(),
      message: 'My message',
      error: myException,
      stackTrace: myStackTrace,
    ));
    

The error field can also hold data for non-error logs. If it stores JSON data (on an object with a toJson() method), the data can be inspected using json_view.

MediaOverridesDebugHelper
´MediaOverridesDebugHelper demo

This allows you to override the theme mode and locale of your app. To use it, follow these steps:

  1. Store its mutable state, e.g., in a global variable:

    final mediaOverrideState = ValueNotifier(MediaOverrideState());
    
  2. Register the helper and supply its state, e.g., in main():

    void main() {
      if (kDebugMode) {
        DebugOverlay.prependHelper(MediaOverrideDebugHelper(
          mediaOverrideState,
          // To support overriding locales, this value must be set and should
          // contain the same locales as passed to [MaterialApp.supportedLocales],
          // [CupertinoApp.supportedLocales] or [WidgetsApp.supportedLocales].
          supportedLocales: supportedLocales,
        ));
      }
    
      runApp(MyApp());
    }
    
  3. When building your MaterialApp/CupertinoApp/WidgetsApp, wrap it in a ValueListenableBuilder that uses the state from step 1:

    ValueListenableBuilder<MediaOverrideState>(
      valueListenable: mediaOverrideState,
      builder: (context, overrideState, child) {
        return MaterialApp(
          // You can access overridden values via [overrideState]:
          themeMode: overrideState.themeMode,
          locale: overrideState.locale,
    
          builder: DebugOverlay.builder(),
          supportedLocales: supportedLocales,
    
          // And your other customizations...
        );
      },
    );
    
PackageInfoDebugHelper
PackageInfoDebugHelper demo

Displays information obtained from package_info_plus.

Custom

To implement your own debug helper, you can use the provided DebugHelper class for the layout.

If your information can be represented with Flutter's DiagnosticsNode, you can use DiagnosticsBasedDebugHelper which automatically provides filtering. This is also used internally by DeviceInfoDebugHelper, MediaQueryDebugHelper, and PackageInfoDebugHelper.

カテゴリー

依存関係

依存関係一覧 9 件

ソースリポジトリ

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

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