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

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

master_detail_scaffold

レスポンシブなマスターディテールスケルトンウィジェットを実装するためのパッケージ

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
19
いいね数
21
Pub ポイント
150

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

flutter pub add master_detail_scaffold

パッケージ概要

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

Flutterパッケージで、レスポンシブなマスターディテールスキャフォルドウィジェットを提供し、さまざまな画面サイズ間でリスト(マスター)と詳細ビュー(ディテール)の間をスムーズにナビゲートできるようにします。デバイスの幅に基づいてレイアウトを自動的に適応させ、モバイル、タブレット、Webプラットフォームで一貫したユーザー体験を提供します。ダッシュボードや管理パネルなど、階層的なコンテンツ表示が必要なデータ主体のアプリに最適です。組み込みの応答性ロジックとカスタマイズ可能なコールバックにより、実装が簡単になります。

用途

  • 応答性のある管理者ダッシュボードの構築
  • データ探索インターフェースの作成
  • 複数のプラットフォームでリスト-詳細ナビゲーションを実装する
  • タブレットおよびデスクトップ向けの適応型レイアウトの設計
  • コンテンツ管理システムの開発

主な機能

  • 画面サイズに応じた自動レイアウトの適応
  • すべての主要なFlutterプラットフォームをサポート
  • カスタマイズ可能なマスターおよび詳細ウィジェット
  • モバイルおよびデスクトップ用の組み込み応答性動作
  • 単一のウィジェットによるシンプルな統合

適している対象

  • クロスプラットフォームUIを構築する開発者
  • 応答性のあるリスト-詳細パターンを必要とするチーム
  • モバイルおよびデスクトップユーザーをターゲットにしたアプリ
  • マスターディテールレイアウトに最小限のボイラープレートを必要とするプロジェクト

注意事項

  • 複雑なレイアウトには追加のスタイリングが必要になる場合があります
  • 非標準的な遷移のカスタマイズが限られている
  • シンプルなリスト-詳細フローに最適
  • 非常に動的なまたはネストされたナビゲーション構造には適していません

元の README

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

master_detail_scaffold

pub package Build Status

A Flutter package that contains widgets that help implement a responsive master-detail layout. The widget is based on the material design scaffold and was based on exploring responsive layouts as covered in this article. As such, it may not suitable for all scenarios (e.g. nested/multiple master-detail layouts) as it has been shared in case there are other members of the community who may find it useful. Go here to see the example running on the web.

NOTE: this uses the imperative Navigator (1.0) APIs. There are currently no plans to migrate this to Navigator 2.0 so those that need Navigator 2.0 should look at forking this project

Getting started

The package exposes a MasterDetailScaffold widget that is built based on Flutter's Scaffold widget. Therefore, you can expect the majority of the properties you're familiar to exist and can be use it in a similar way you would normally do with a Scaffold widget. Create a class and use the MasterDetailScaffold widget within your build method

MasterDetailScaffold(
    onDetailsPaneRouteChanged:
        (String route, Map<String, String> parameters) {
    setState(() {
        if (route == RouteNames.itemDetails) {
        _selectedItem = content.items.firstWhere(
            (item) => item.id == parameters['id'],
            orElse: null);
        return;
        }
        _selectedItem = null;
    });
    },
    twoPanesWidthBreakpoint: 600,
    initialRoute: RouteNames.home,
    detailsRoute: RouteNames.itemDetails,
    initialAppBar: AppBar(
    title: Text('Master-detail Flow Demo'),
    ),
    masterPaneWidth: 400,
    masterPaneBuilder: (BuildContext context) => ItemsList(
    selectedItem: _selectedItem,
    ),
    detailsPaneBuilder: (BuildContext context) =>
        ItemDetails(item: _selectedItem),
    detailsAppBar: AppBar(
    // the [Builder] widget is needed to ensure that the widget for displaying the title gets rebuilt based on the selected item.
    // Without the [Builder] widget, the title is set to the value that was originally passed through
    title: Builder(
        builder: (context) => Text(_selectedItem.title),
    ),
    ),
    floatingActionButton: Visibility(
    visible: _selectedItem != null,
    child: Builder(
        builder: (context) => FloatingActionButton(
        child: Icon(Icons.reply),
        onPressed: () {
            ScaffoldMessenger.of(context).showSnackBar(
            SnackBar(
                content: Text('Replying to ${_selectedItem.title}'),
            ),
            );
        },
        ),
    ),
    ),
);

The key parts are

  • twoPanesWidthBreakpoint: the width breakpoint for showing both the master and details pane together. The back button is hidden whe both panes are visible
  • initialRoute: the name of the route use when no details are shown in the details pane
  • detailsRoute: the name of the route to use when details are shown in the details pane
  • masterPaneWidth: the width of the master pane. Applicable when both the master and details pane are shown
  • masterPaneBuilder: determines what to show in the master pane. This is typically a list of items and is left to developers to implement what they should render here
  • detailsPaneBuilder: determines what to show in the details pane. When both the master and details pane are shown, it is assumed to take the remaining of width of the screen
  • onDetailsPaneRouteChanged: the callback trigger when the route in the details pane changes. Use this to find out get the route/path and query string parameters so you can display the appropriate content

To trigger navigation in the details pane, you can retrieve the navigator associated with the details pane by calling MasterDetailScaffold.of(context).detailsPaneNavigator. Normally, this wouldn't be needed and you would only need to call Navigator.of(context) but this doesn't appear to get the navigator associated with the details pane. URI-based navigation is expected via named routes. By default the page transition applied is the same as the MaterialPageRoute, though when both panes are shown no animation is used when the details change. Should you want to use a different transition style, this can be specified using the pageRouteBuilder property.

Note that I've found that entering a URL that should go to a specific details page doesn't work. This is likely due to the fact that Flutter's web support for web development isn't stable yet. Should you find a solution for this, please submit a pull request.

Should you want to see this running, a complete example can be found in the GitHub repository.

カテゴリー

ソースリポジトリ

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

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