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

responsive_grid 표지
패키지 상세v2.4.4

responsive_grid

Flutter용 반응형 그리드 레이아웃 및 목록

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
1.2만
좋아요
272
Pub 점수
115

패키지 설치

flutter pub add responsive_grid

패키지 개요

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

다양한 플랫폼에서 반응형 그리드 레이아웃과 목록을 가능하게 하는 플러터 패키지입니다. 화면 크기에 따라 자동으로 열 수와 간격을 조정하여 안드로이드, iOS, 웹, 맥OS, 윈도우, 리눅스에서 최적의 UI 표시를 보장합니다. 복잡한 미디어 쿼리 로직을 작성하지 않고도 적응형 인터페이스를 쉽게 만들 수 있습니다. 대시보드, 제품 카탈로그, 콘텐츠 그리드 등이 부드럽게 확장되어야 하는 경우에 이상적입니다.

사용 사례

  • 반응형 대시보드 구축
  • 적응형 제품 그리드 만들기
  • 크로스 플랫폼 레이아웃 설계
  • 행에 동적 콘텐츠 표시
  • 유체 리스트 구조 구현

주요 기능

  • 화면 크기에 따라 열을 자동으로 조정합니다
  • 모든 주요 플러터 플랫폼을 지원합니다
  • 최소 설정으로 간단한 API
  • 사용자 정의 가능한 간격 및 정렬
  • 내장된 반응형 브레이크포인트

적합한 대상

  • 다중 플랫폼 앱을 개발하는 개발자
  • 유연한 레이아웃이 필요한 UI 디자이너
  • 적응형 콘텐츠 그리드가 필요한 프로젝트
  • 반응형 디자인을 우선시하는 팀
  • 다양한 기기 크기에 대응하는 앱

고려 사항

  • 복잡한 중첩 레이아웃에 맞게 조정이 필요할 수 있습니다
  • 매우 큰 데이터 세트에 대한 성능 영향
  • 기본 그리드 설정을 초과한 사용자 정의는 제한적입니다
  • 매우 동적 또는 애니메이션된 그리드에는 적합하지 않음
  • 부모 위젯에서 제약 조건을 올바르게 사용하는 데 의존함

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

responsive_grid

pub package

Responsive Grid Layout, List and many Utilities for Flutter, to achieve good UI look and feel for different screen sizes

Responsive Grid Layout

With ResponsiveGridRow and ResponsiveGridCol you can get the same behavior of bootstrap Grid System

Give every col the width it shall occupy at every size category assuming the total width is 12 (by default)

        ResponsiveGridRow(
          children: [
            ResponsiveGridCol(
              lg: 12,
              child: Container(
                height: 100,
                alignment: Alignment(0, 0),
                color: Colors.purple,
                child: Text("lg : 12"),
              ),
            ),
            ResponsiveGridCol(
              xs: 6,
              md: 3,
              child: Container(
                height: 100,
                alignment: Alignment(0, 0),
                color: Colors.green,
                child: Text("xs : 6 \r\nmd : 3"),
              ),
            ),
            ResponsiveGridCol(
              xs: 6,
              md: 3,
              child: Container(
                height: 100,
                alignment: Alignment(0, 0),
                color: Colors.orange,
                child: Text("xs : 6 \r\nmd : 3"),
              ),
            ),
            ResponsiveGridCol(
              xs: 6,
              md: 3,
              child: Container(
                height: 100,
                alignment: Alignment(0, 0),
                color: Colors.red,
                child: Text("xs : 6 \r\nmd : 3"),
              ),
            ),
            ResponsiveGridCol(
              xs: 6,
              md: 3,
              child: Container(
                height: 100,
                alignment: Alignment(0, 0),
                color: Colors.blue,
                child: Text("xs : 6 \r\nmd : 3"),
              ),
            ),
          ],
        )

Responsive Grid List

ResponsiveGridList works differently in that you only specify a desired width for the items and spacing, and it will decide how many items shall fit in a line, and the width of the item and spacing will change (only small change) to fill the entire width

    ResponsiveGridList(
        desiredItemWidth: 100,
        minSpacing: 10,
        children: List.generate(20, (index)=> index+1).map((i) {
          return Container(
            height: 100,
            alignment: Alignment(0, 0),
            color: Colors.cyan,
            child: Text(i.toString()),
          );
        }).toList()
    )

Responsive Staggered Grid List

The same as the ResponsiveGridList, but arranges items in columns inside one big row, so every item has independent height

Utilities

ResponsiveWidget , ResponsiveBuilder, ResponsiveLayoutBuilder and responsiveValue()

To provide a custom responsive Widget, Builder or a single value, for every size tier

ResponsiveLocalWidget, ResponsiveLocalBuilder and ResponsiveLocalLayoutBuilder

To provide a responsive Widget or Builder for its own width, not the viewport's, they are just wrappers on top of flutter LayoutBuilder

Warning: make sure not to use any of them inside unbounded width widget, as the width will be read infinity

ResponsiveWidget and ResponsiveBuilder

To create widgets conditionally for every size tier

ResponsiveLayoutBuilder

To create different layouts for every size tier, for example put children inside a Column for XS and in a Row from MD and larger

ResponsiveLayoutBuilder(
                  xs: (BuildContext context, List<Widget> children) => Column(
                    children: children,
                  ),
                  md: (BuildContext context, List<Widget> children) => Row(
                    children: children,
                  ),
                  children: .....,
                ),
responsiveValue()

A conditional value on size tier, may be used to achieve any complicated behavior, for example say you have a GridView you can make the crossAxisCount increase with the width

GridView.count(
            crossAxisCount: responsiveValue(context, xs: 2, sm: 3, md: 4, lg: 6, xl: 7),
            children: .....
          )

Another example you can make a widget visible in small sizes and hidden starting from MD tier

Visibility(
      visible: responsiveValue(context, xs: true, md: false),
      child: .....)
ResponsiveLocalWidget and ResponsiveLocalBuilder

To create widgets conditionally for each specified available width for it

ResponsiveLocalLayoutBuilder

To Layout widgets conditionally for each specified available width for them, for example say you want to put children inside a Column if available space width is less than 500 and in a Row if larger

ResponsiveLocalLayoutBuilder(configs: [
                  ResponsiveLayoutBuilderConfig(
                    upToWidth: 500,
                    builder: (BuildContext context, List<Widget> children) => Column(
                      children: children,
                    ),
                  ),
                  ResponsiveLayoutBuilderConfig(
                    upToWidth: double.infinity,
                    builder: (BuildContext context, List<Widget> children) => Row(
                      children: children,
                    ),
                  )
                ], children: .....)

Override breakpoints

Add before attaching App widget

ResponsiveGridBreakpoints.value = ResponsiveGridBreakpoints(
  xs: 600,
  sm: 905, 
  md: 1240,
  lg: 1440,
);

카테고리

소스 저장소

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