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

multi_screen_layout のカバー
パッケージ詳細v3.1.0

multi_screen_layout

複数画面のユーザー体験を簡単に構築できるウィジェットのコレクション

Android
30日間ダウンロード
43
いいね数
26
Pub ポイント
140

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

flutter pub add multi_screen_layout

パッケージ概要

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

ダブルスクリーンおよび折りたたみ式デバイスを含む、マルチスクリーンユーザー体験の作成を簡素化することを目的としたFlutterパッケージです。複数のディスプレイ間でのレイアウト調整を処理するカスタマイズ可能なウィジェットのセットを提供し、シームレスな遷移と応答性のあるデザインを保証します。複雑な画面管理ロジックを抽象化することで、開発者はプラットフォーム固有の知識に深く立ち入ることなくUI/UXに集中できます。現代的なAndroidデバイス(柔軟なフォームファクター)向けアプリに最適です。

用途

  • 折りたたみ式スマートフォン用のアプリを開発する
  • スプリットスクリーンレイアウトの作成
  • 二画面用の適応型インターフェースの設計
  • Androidタブレット用の応答性のあるUIを開発する
  • 動的スクリーン構成のサポート

主な機能

  • マルチスクリーンレイアウト用の事前構築ウィジェット
  • 自動レイアウトの適応
  • レスポンシブデザインのサポート
  • 既存のFlutterプロジェクトとの簡単な統合
  • Androidデュアルスクリーンデバイスに最適化

適している対象

  • 折りたたみ式Androidデバイスをターゲットにする開発者
  • アダプティブUIを構築するチーム
  • スプリット画面機能を必要とするアプリ
  • 革新的デバイスサポートに焦点を当てたFlutterプロジェクト
  • 動的スクリーンサイズと連携するUIデザイナー

注意事項

  • Androidプラットフォームに限定
  • マルチスクリーンの利用ケースを理解する必要があります
  • 実機での追加テストが必要になる可能性があります
  • 折りたたみ式または二画面アプリ以外には適していません
  • デバイスのハードウェア機能に依存します

元の README

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

Multi Screen Layout for Flutter

pub package

A collection of Widgets that make multi screen user experiences easy to build

Supported Devices

  • [x] Surface Duo
  • [x] Surface Duo 2
  • [x] Galaxy Z Fold 1 (Flex Mode)
  • [x] Galaxy Z Fold 2 (Flex Mode)
  • [x] Galaxy Z Flip (Flex Mode)
  • [ ] LG Wing

If you know of other devices that could support multi screen layouts, please submit a PR and add them to this list.

Install

In your pubspec.yaml

dependencies:
  multi_screen_layout: ^3.1.0

In your app build.gradle

dependencies { 
    implementation "androidx.window:window:1.0.0-rc01"
    implementation 'androidx.window:window-java:1.0.0-rc01'
}

Testing

For testing without access to these physical devices you can use some specific emulators.

  • 6.7 Horizontal Fold-in emulator available in Android Studio
  • 7.6 Fold-in with outer display emulator available in Android Studio
  • 8 Fold-out emulator available in Android Studio
  • Surface Duo Emulator available here.

Layouts

TwoPageLayout

Displays two Widgets, one per screen.

On a Microsoft dual screen device when the app is being spanned across two screens, TwoPageLayout displays both widgets, one per screen. This is designed to help you build Two Page, Dual View, and Companion Pane dual screen app patterns from Microsoft.

On a folding screen device when the display could be utilized to split content areas, TwoPageLayout displays both widgets, one per content area. This is designed to help you build Flex Mode user experiences. You can read more about how when to split content is decided in the AndroidX WindowManager documentation.

On a single screen device, or when the app is only running on a single screen, only child will be displayed.

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return TwoPageLayout(
      child: Scaffold(body: Center(child: Text('Hello from page 1!'))),
      secondChild: Scaffold(body: Center(child: Text('Hello from page 2!'))),
    );
  }
}
Surface Duo Example

Two Page 1

Two Page 2

Samsung Z Fold 2 Flex Mode Example

See video here

MasterDetailLayout

Very similar to TwoPageLayout. This layout has better support for having related, "deeper", content in the second page that would usually be accessed by navigating to a new page.

It's common to use this type of layout when you have a list of items that when tapped let you view a detailed view of the item. Email and instant messaging apps are good examples of this.

On a single screen device, or when the app is only running on a single screen, master will display first. When isSelected is true, detail is displayed as a new page on top of master, similar to using Navigator.push.

When displaying on 2 screens, both master and detail display at the same time and no navigation occurs. Even when isSelected is false.

Similar to TwoPageLayout, on a folding screen device when the screen is half opened the screen is treated as a dual screen device.

MasterDetailLayout also handles switching between spanned and non-spanned modes appropriately, so the UI will be the same if you select and then span, or span and then select.

class MasterDetailLayoutExample extends StatefulWidget {
  @override
  _MasterDetailLayoutExampleState createState() =>
      _MasterDetailLayoutExampleState();
}

class _MasterDetailLayoutExampleState extends State<MasterDetailLayoutExample> {
  int selectedItem;

  @override
  Widget build(BuildContext context) {
    return MasterDetailLayout(
      master: EmailList(onItemSelected: (selected) {
        setState(() {
          selectedItem = selected;
        });
      }),
      detail: EmailDetail(itemNumber: selectedItem),
      isSelected: selectedItem != null,
    );
  }
}
Surface Duo Example

MasterDetail

Samsung Z Fold 2 Flex Mode Example

See video here

Direct Data Access

Direct access is for advanced uses cases. The above layouts should be suitable for most apps.

There may be cases where you want to access multi screen information instead of just using the above layout widgets. Here is how to do that.

MultiScreenInfo

MultiScreenInfo is a Widget that lets you access information about the device directly in your Widget tree, it will rebuild when the data changes.

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: MultiScreenInfo(
        builder: (info) {
          return Column(
            children: <Widget>[
              Text('The below information is from the Surface Duo SDK'),
              Text('isAppSpanned: ${info.surfaceDuoInfoModel.isSpanned}'),
              Text('hingeAngle: ${info.surfaceDuoInfoModel.hingeAngle}'),
            ],
          );
        },
      ),
    );
  }
}
PlatformHandlers

If you need access to information about the device outside of the Widget tree, you can also make platform calls yourself.

SurfaceDuoPlatformHandler
Future getSurfaceDuoInfo() async {
    var hingeAngle = await SurfaceDuoPlatformHandler.getHingeAngle();
    var isDual = await SurfaceDuoPlatformHandler.getIsDual();
    var isSpanned = await SurfaceDuoPlatformHandler.getIsSpanned();
    var nonFunctionalBounds = await SurfaceDuoPlatformHandler.getNonFunctionalBounds();
  }

Extra Documentation

カテゴリー

ソースリポジトリ

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

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