패키지, 저장소 및 앱 카테고리 검색

master_detail_scaffold 표지
패키지 상세v2.0.0

master_detail_scaffold

반응형 마스터-디테일 스케letal 위젯을 구현하기 위한 패키지

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
19
좋아요
21
Pub 점수
150

패키지 설치

flutter pub add master_detail_scaffold

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

다양한 화면 크기에서 목록(마스터)과 상세 보기(디테일) 간의 원활한 탐색을 가능하게 하는 반응형 마스터-디테일 스캐폴드 위젯을 제공하는 플러터 패키지입니다. 장치 너비에 따라 레이아웃을 자동으로 조정하여 모바일, 태블릿, 웹 플랫폼에서 일관된 사용자 경험을 제공합니다. 대시보드나 관리판과 같이 계층적 콘텐츠를 표시해야 하는 데이터 중심 앱에 적합합니다. 내장된 반응성 로직과 사용자 정의 가능한 콜백을 통해 구현을 간소화합니다.

사용 사례

  • 반응형 관리 대시보드 구축
  • 데이터 탐색 인터페이스 만들기
  • 다중 플랫폼에서 목록-세부 정보 탐색 구현
  • 태블릿과 데스크톱용 적응형 레이아웃 설계
  • 콘텐츠 관리 시스템 개발

주요 기능

  • 화면 크기에 따라 자동 레이아웃 적응
  • 모든 주요 플러터 플랫폼 지원
  • 사용자 정의 가능한 마스터 및 세부 위젯
  • 모바일 및 데스크톱용 내장 반응형 동작
  • 단일 위젯을 통한 간편한 통합

적합한 대상

  • 크로스 플랫폼 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.

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.