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

패키지 상세v3.1.0

gap

Column 및 Row 등의 Flex 위젯 또는 스크롤 뷰 내부에 쉽게 간격을 추가할 수 있는 Flutter 위젯입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
47.3만
좋아요
1천
Pub 점수
160

패키지 설치

flutter pub add gap

패키지 개요

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

gap 패키지는 Column, Row 및 스크롤 뷰와 같은 Flex 컨테이너 내에서 일관된 간격을 쉽게 추가할 수 있는 간단한 Flutter 위젯을 제공합니다. 수동으로 EdgeInsets 또는 SizedBox를 사용할 필요 없이 자식 요소 사이에 간격을 삽입하는 깔끔하고 선언적인 방법을 제공합니다. 중첩 레이아웃을 가진 UI에서 레이아웃의 가독성을 향상시키고 반복 코드를 줄이는 데 이상적입니다. 이 패키지는 모든 주요 플랫폼을 지원하며 기존의 Flutter 프로젝트와 원활하게 통합됩니다.

사용 사례

  • Column 및 Row 레이아웃에 균일한 간격 추가
  • 스크롤 가능한 목록의 간격 단순화
  • 다양한 화면 크기 간의 UI 일관성 향상
  • 복잡한 중첩 레이아웃에서 반복 코드 줄이기
  • 최소한의 코드로 반응형 디자인 만들기
  • UI 개발에서 개발자 생산성 향상

주요 기능

  • 직관적인 구문을 가진 최소한의 API
  • 모든 플러터 플랫폼을 지원합니다
  • 스크롤 가능한 뷰에서 간격 자동 처리
  • 일반적인 경우에서 SizedBox 또는 EdgeInsets가 필요하지 않습니다
  • 다른 레이아웃 위젯과 조합 가능
  • 경량이며 종속성 없음

적합한 대상

  • 더 깔끔한 레이아웃 코드를 원하는 개발자
  • 자주 사용되는 열과 행을 가진 프로젝트
  • 일관된 간격이 필요한 UI 중심 애플리케이션
  • 유지보수성과 가독성을 우선시하는 팀
  • Flutter 초보자가 레이아웃 패턴을 배우고 있습니다
  • 균일한 간격을 가진 다중 플랫폼 대상 앱

고려 사항

  • 간격이 없는 간단한 레이아웃에는 필요하지 않음
  • 매우 큰 목록에서는 약간의 오버헤드가 발생할 수 있습니다
  • 다른 레이아웃 최적화 기법과 함께 사용하는 것이 가장 좋습니다
  • 고급 간격 솔루션(예: 사용자 정의 렌더링 개체)을 대체하지 않습니다
  • Flex 컨테이너 내부의 간격에 제한됨
  • Flutter 레이아웃 시스템에 대한 이해가 필요합니다

원본 README

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

Gap

Flutter widgets for easily adding gaps inside Flex widgets such as Columns and Rows or scrolling views.

Pub

Introduction

When it comes to add empty space between widgets inside a Column or a Row, we have multiple options:

  • We can either add a Padding around these widgets but it's very verbose
  • Or we can add SizedBox widgets between them.

Gap is another option. It's like SizedBox but you don't have to know if it's inside a Row or a Column. So that it's less verbose than using a SizedBox.

Getting started

In your library add the following import:

import 'package:gap/gap.dart';

Then you just have to add a Gap inside a Column or a Row with the specified extent.

return Column(
  children: <Widget>[
    Container(color: Colors.red, height: 20),
    const Gap(20), // Adds an empty space of 20 pixels.
    Container(color: Colors.red, height: 20),
  ],
);

The Gap widget also works inside Scrollable widgets such as ListViews. In these cases, it will occupy the space in the same direction as the Scrollable.

MaxGap

This package also comes with a MaxGap widget. The MaxGap widget will try to fill the available space in a Column or a Row with the specified size. If the available space is lesser than the specified size, the MaxGap widget will only take the available space.

It's useful when you want to have a gap that shrinks to avoid an overflow otherwise.

Other parameters

By default a Gap will have no extent in the opposite direction of the Flex parent. If you want the Gap to have a color, you'll have to set the color and the crossAxisExtent parameters. You can also use the Gap.expand constructor to expand the Gap in the opposite direction of the Flex parent.

SliverGap

There is also a Sliver version of the Gap widget:

return CustomScrollView(
  slivers: <Widget>[
    const SliverGap(20), // Adds an empty space of 20 pixels.
  ],
);

Changelog

Please see the Changelog page to know what's recently changed.

Contributions

Feel free to contribute to this project.

If you find a bug or want a feature, but don't know how to fix/implement it, please fill an issue.
If you fixed a bug or implemented a feature, please send a pull request.

카테고리

소스 저장소

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

순위