搜尋套件、儲存庫與 APP 分類

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 設備的開發者
  • 建構自適應 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

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。