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

パッケージ詳細v0.7.0

flutter_displaymode

Android プラットフォーム上でディスプレイモード(解像度、リフレッシュレート)を設定するための Flutter プラグインです。対応デバイスで高リフレッシュレートを有効にできます。

Android
30日間ダウンロード
12.5万
いいね数
220
Pub ポイント
160

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

flutter pub add flutter_displaymode

パッケージ概要

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

flutter_displaymode は、Android デバイス上で解像度やリフレッシュレートなどの表示モードをプログラムで設定できる Flutter プラグインです。対応ハードウェアで高リフレッシュレートを有効にすることで、パフォーマンスと視覚的品質を最適化するのに特に役立ちます。このプラグインは Android のディスプレイ設定に直接アクセスでき、アプリがデバイスの機能に応じて動的に適応できるようにします。この機能は Android 固有であるため、iOS はサポートしていません。

用途

  • 高リフレッシュレート画面でのアプリパフォーマンスの最適化
  • ゲームアプリ向けに90Hzまたは120Hzのリフレッシュレートを有効にする
  • より良い視覚的明瞭性のための表示解像度の調整
  • アニメーションが多く含まれるアプリケーションにおけるUIの滑らかさの向上
  • さまざまな画面構成での表示動作のテスト

主な機能

  • Androidディスプレイ解像度およびリフレッシュレートを設定する
  • 互換デバイスで高リフレッシュレートモードをサポートしています
  • 表示モードを設定するための簡単な API を提供します
  • Android 固有
  • rootアクセスを必要としない

適している対象

  • Androidゲーム開発者
  • 高性能UIレンダリングを必要とするアプリ
  • プレミアムAndroidデバイスをターゲットとする開発者
  • 視覚の正確性に焦点を当てたアプリケーション
  • ツールの表示機能をテスト

注意事項

  • Androidデバイスでのみ動作します
  • 動的ディスプレイモードの変更をサポートするデバイスが必要です
  • すべてのAndroidバージョンで機能しない可能性があります
  • 変更はシステムまたはユーザーによって元に戻される可能性があります
  • 特定のハードウェア機能に限定

元の README

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

Flutter Display Mode

pub package

A Flutter plugin to set display mode in Android. This is useful to enable high refresh rate in devices with discrete framerates like 60Hz, 90Hz etc. This library is ineffective on devices with LTPO panels and iOS devices with ProMotion.

This library should be used as a temporary fix to #35162 until this API gets added to Flutter engine itself.

Getting Started

Add library to pubspec then and rebuild your app:

flutter pub add flutter_displaymode
Set to highest/lowest framerate

Use helper functions FlutterDisplayMode.setHighRefreshRate or FlutterDisplayMode.setLowRefreshRate to switch to highest or lowest refresh rate maintaining current resolution.

// current: #1 1440x3120 @ 60Hz
// new: #2 1440x3120 @ 90Hz
await FlutterDisplayMode.setHighRefreshRate();

// current: #2 1440x3120 @ 90Hz
// new: #1 1440x3120 @ 60Hz
await FlutterDisplayMode.setLowRefreshRate();
Get supported modes

FlutterDisplayMode.supported returns all the modes that can be set as the preferred mode. This always returns DisplayMode.auto as one of the modes.

import 'package:flutter_displaymode/flutter_displaymode.dart';

try {
  modes = await FlutterDisplayMode.supported;
  modes.forEach(print);

  /// On OnePlus 7 Pro:
  /// #0 0x0 @0Hz // Automatic
  /// #1 1080x2340 @ 60Hz
  /// #2 1080x2340 @ 90Hz
  /// #3 1440x3120 @ 90Hz
  /// #4 1440x3120 @ 60Hz

  /// On OnePlus 8 Pro:
  /// #0 0x0 @0Hz // Automatic
  /// #1 1080x2376 @ 60Hz
  /// #2 1440x3168 @ 120Hz
  /// #3 1440x3168 @ 60Hz
  /// #4 1080x2376 @ 120Hz
} on PlatformException catch (e) {
  /// e.code =>
  /// noAPI - No API support. Only Marshmallow and above.
  /// noActivity - Activity is not available. Probably app is in background
}
Get active mode

FlutterDisplayMode.active fetches the currently active mode. This is not always the preferred mode set by FlutterDisplayMode.setPreferredMode. It can be altered by the system based on the display settings.

final DisplayMode m = await FlutterDisplayMode.active;
Set preferred mode

FlutterDisplayMode.setPreferredMode changes the preferred mode. It is upto the system to use this mode. Sometimes system can choose not switch to this based on internal heuristics. Check FlutterDisplayMode.active to see if it actually switches.

/// This setting is per session. 
/// Please ensure this was placed with `initState` of your root widget.
await FlutterDisplayMode.setPreferredMode(modes[1]);
Get preferred mode

FlutterDisplayMode.preferred returns the currently preferred mode. If not manually set with FlutterDisplayMode.setPreferredMode then it will be DisplayMode.auto.

final DisplayMode m = await FlutterDisplayMode.preferred;

You can check out a complete example here.

カテゴリー

ソースリポジトリ

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