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

패키지 상세v2.2.0

flutter_gutter

UI를 더럽지 않게 유지하세요! 위젯 간의 모든 시각적 간격이 일관되며 축 방향에 맞춰 조정되고 화면 크기에 반응하도록 보장하세요.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
3.1천
좋아요
65
Pub 점수
150

패키지 설치

flutter pub add flutter_gutter

패키지 개요

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

Flutter Gutter는 다양한 화면 크기와 축 방향에서 위젯 간 일관된 간격을 보장하는 반응형 UI 유틸리티 패키지입니다. 방향(수평 또는 수직)과 기기 차원에 따라 패딩과 마진을 자동으로 조정함으로써 레이아웃 관리를 단순화하여 개발자가 수동 계산 없이 깔끔하고 정렬된 인터페이스를 유지할 수 있도록 도와줍니다. 어떤 플랫폼에서도 매끄럽고 확장 가능한 디자인을 완성하기에 이상적입니다.

사용 사례

  • 일관된 간격을 사용하여 반응형 레이아웃 만들기
  • 방향 간 패딩/여백 조정 자동화
  • 다중 플랫폼 앱을 위한 적응형 UI 구축
  • 동적 위젯 배치에서 시각적 조화 유지
  • 최소한의 코드로 복잡한 레이아웃 로직을 단순화
  • 균일한 간격을 통한 접근성 보장

주요 기능

  • 자동 축 인식 간격
  • 화면 크기 변경에 반응
  • 모든 주요 플랫폼을 지원합니다
  • 필요한 최소한의 보일러플레이트
  • 수평 및 수직 간격을 위한 직관적인 API
  • 기존 플러터 위젯과의 원활한 통합

적합한 대상

  • 반응형 디자인에 집중하는 개발자
  • 크로스 플랫폼 애플리케이션을 개발하는 팀
  • 일관된 간격을 구현하는 UI/UX 디자이너
  • 적응형 레이아웃을 필요로 하는 프로젝트
  • Flutter 레이아웃 원칙을 배우는 초보자
  • 다양한 화면 크기 대상 앱

고려 사항

  • 매우 맞춤형 간격 요구 사항을 위해 조정이 필요할 수 있습니다
  • 간격과 관련된 기능에 한정됨
  • 레이아웃 외 사용 사례에는 적합하지 않습니다
  • Flutter의 레이아웃 시스템의 올바른 사용에 달려 있음
  • 복잡한 디자인을 위한 다른 레이아웃 유틸리티와 함께 최적의 조합
  • 플렉스 또는 그리드와 같은 완전한 레이아웃 프레임워크를 대체하지 않습니다

원본 README

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

Flutter Gutter

Pub Version GitHub Workflow Status

Ensure all visual gaps between your widgets are consistent, adapted to the axis direction, and respond to screen size!

Core Features

Provides a Gutter and Margin that correspond to Material Design's Responsive Layout system.

Gutters and margins:

  1. Create a vertical gap in vertical layouts (Column, vertical Scrollable, etc) and a horizontal gap in horizontal layouts (Row, horizontal Scrollable, etc).
  2. Size the gap according to the current screen size and Material Design's corresponding breakpoint definition (small gap on small screens, larger gap on large screens)

GutterTiny, GutterSmall, GutterLarge and GutterExtraLarge all provide gaps that are factors of the base gutter size for situations where larger or smaller gaps are more appropriate. By default, each successive gutter size is a factor of 2 larger than the previous. For convenience, alternative constructors are provided (Gutter.tiny, etc.) for each gutter size.

For more flexibility, you can also use the provided extension on BuildContext to reference the gutter and margin sizes directly (context.gutter, context.gutterLarge, context.margin, etc).

Use Gap to create an axis aligned spacing with an explicit size.

Supported Widgets

Flutter Gutter's widgets traverse up the widget tree until they find an ancestor that meets one of the following conditions:

  1. GutterConfiguration.maybeOf(context).customWidgetToAxis(widget) returns a non-null Axis (this is a custom function that lets you extend Flutter Gutter to support arbitrary widgets).
  2. widget is a scrollable with a defined axis.
  3. widget has an Axis direction attribute (for example, Flutter Gutter supports Boxy's widgets automatically).

Note that case 3 means that ANY widget with an axis is supported, however this is a dynamic check which means that the Dart compiler will not be able to tree shake out any axis attributes on any widget. This may increase your app's bundle size by a very small amount.

I have a Github issue against Flutter to add an explicit axis scope to Flutter which would resolve this limitation. If you like using Flutter Gutter and want to see it improved, please upvote the linked issue.

Example

Without flutter_gutter you have to manually specify the axis direction (by using height or width) and specify size of the gap yourself:

return Column(
  children: [
    const Text('I hate using sized box.'),
    SizedBox(height: 10),
    const Text('If only there were a better way...'),
  ],
);

With flutter_gutter the Gutter widget identifies that it's in a vertical layout (Column) and automatically creates a vertical gap. It also looks up the screen size and sizes the gap accordingly so you don't have to specify a gap size manually:

return Column(
  children: [
    const Text('I hate using sized box.'),
    Gutter(),
    const Text('And now I don\'t have to!'),
  ],
);

To use the gutter sizes directly, use the extension on context:

return Padding(
  padding: EdgeInsets.only(left: context.gutter, right: context.gutterSmall),
  child: Text('This is the margin size on this device: ${context.margin}'),
);

To use Gutter with custom widgets that don't expose an axis argument or to override the default gutter spacing or scaling, use GutterConfiguration:

return GutterConfiguration(
  data: GutterConfigurationData(
    widgetToAxis: (widget) {
      if (widget is MyCustomColumn) {
        return Axis.vertical;
      }
      return null;
    },
  ),
  child: MyCustomColumn(
    children: [
      const Text('This widget isn\'t supported by `Gutter` ).'),
      Gutter(),
      const Text('But with `GutterConfiguration` I can make Gutter work with any widget!'),
    ],
  ),
);

Why not just use the existing Gap package?

Gap and Flutter Gutter are very similar, but Flutter Gutter does a few extra things Gap does not:

  1. Auto sizes gap spacing according to the Material breakpoints system (see "Core Features" above).
  2. Detects the axis of ANY widget that exposes an Axis direction attribute or getter (see "Supported Widgets" above).
  3. Allows you to add support for arbitrary widgets using GutterConfiguration and widgetToAxis.

Personally, I especially appreciate feature 1 as it makes it easier for me to add spacing and ensures that spacing and padding in different parts of my app are consistently sized. However, if none of the above features are important to you, you'll likely prefer the Gap package!

카테고리

의존성

의존성 목록 1 개

  • flutter_adaptive_scaffold>=0.3.0 <1.0.0

소스 저장소

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