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

パッケージ詳細v2.2.0

flutter_gutter

UIをゴミ箱から脱出させましょう!ウィジェット間のすべての視覚的ギャップが一貫性があり、軸方向に適応し、画面サイズに応じて反応することを確認してください。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
3120
いいね数
65
Pub ポイント
150

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

flutter pub add flutter_gutter

パッケージ概要

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

Flutter Gutter は、さまざまな画面サイズおよび軸方向でウィジェット間のスペースを一貫して保つレスポンシブUIユーティリティパッケージです。方向(水平または垂直)とデバイスの寸法に基づいて、パディングやマージンを自動的に調整することで、レイアウト管理を簡素化し、開発者が手動計算なしにクリーンで整列されたインターフェースを維持できるようにします。あらゆるプラットフォームで洗練された見た目になる、滑らかでスケーラブルなデザインを作成するのに最適です。

用途

  • 一貫した余白を使用してレスポンシブレイアウトを作成する
  • 向きにわたるパディング/マージンの調整を自動化する
  • マルチプラットフォームアプリ用の柔軟なUIの構築
  • 動的なウィジェット配置における視覚的調和の維持
  • 最小限のコードで複雑なレイアウト論理を簡素化する
  • 均一な間隔によるアクセシビリティの確保

主な機能

  • 自動的な軸対応の間隔
  • 画面サイズの変更に応じる
  • すべての主要プラットフォームをサポートしています
  • 必要な最小限のボイラープレート
  • 水平および垂直ギャップ用の直感的な API
  • 既存のFlutterウィジェットとのシームレスな統合

適している対象

  • レスポンシブデザインに焦点を当てる開発者
  • クロスプラットフォームアプリケーションを構築するチーム
  • 一貫したスペースを実装するUI/UXデザイナー
  • アダプティブレイアウトを必要とするプロジェクト
  • Flutterレイアウトの原則を学ぶ初心者
  • さまざまな画面サイズをターゲットにしたアプリ

注意事項

  • 非常にカスタムされたスペースの要件には調整が必要になる場合があります
  • スペース関連の機能に限定される
  • レイアウト以外の用途には適していません
  • Flutterのレイアウトシステムの正しい使用に依存する
  • 複雑なデザインには、他のレイアウトユーティリティと組み合わせるのが最適です
  • Flex や Grid のような完全なレイアウトフレームワークを置き換えるものではありません

元の 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

ソースリポジトリ

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