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

パッケージ詳細v3.1.0

gap

Column や Row などの Flex ウィジェット、またはスクロールビュー内に簡単にギャップを追加するための Flutter ウィジェット。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
47.3万
いいね数
1020
Pub ポイント
160

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

flutter pub add gap

パッケージ概要

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

gap パッケージは、Column、Row、スクロールビューなどの Flex コンテナ内で一貫したスペースを簡単に追加できるシンプルな Flutter ウィジェットを提供します。手動で EdgeInsets や SizedBox を使用する必要がなく、子要素の間にギャップを挿入するための明確で宣言的な方法を提供します。ネストされたレイアウトを持つ UI でのレイアウトの可読性向上とボイラープレートコードの削減に最適です。このパッケージはすべての主要プラットフォームをサポートしており、既存の Flutter プロジェクトとシームレスに統合できます。

用途

  • Column および Row レイアウトに均一な余白を追加する
  • スクロール可能なリスト内の余白の簡略化
  • 異なる画面サイズ間でのUIの一貫性の向上
  • 複雑なネストされたレイアウトにおけるボイラープレートの削減
  • 最小限のコードでレスポンシブデザインを作成する
  • UI開発における開発者の生産性の向上

主な機能

  • 直感的な構文を備えた最小限の API
  • すべての Flutter プラットフォームをサポートしています
  • スクロール可能なビューでのスペースの自動処理
  • 一般的なケースでは 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.

カテゴリー

ソースリポジトリ

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

ランキング