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

spaces 표지
패키지 상세v0.5.0

spaces

일관되고 반응형 앱을 구축하기 위해 전역 간격 상수를 정의합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
31
좋아요
18
Pub 점수
130

패키지 설치

flutter pub add spaces

패키지 개요

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

spaces 패키지는 Flutter 애플리케이션 전체에서 일관되고 반응형 여백을 보장하기 위해 전역적으로 정의된 여백 상수를 제공합니다. 마진, 패딩 및 간격에 대한 사전 정의된 확장 가능한 값을 제공함으로써 다양한 화면 크기와 플랫폼에서 UI 개발을 단순화합니다. 이 패키지는 반응형 레이아웃과 함께 사용하도록 설계되어, 개발자가 값들을 하드코딩하지 않고도 시각적 조화를 유지할 수 있도록 합니다. 모든 주요 Flutter 플랫폼을 지원하므로 균일한 간격 동작이 필요한 크로스플랫폼 프로젝트에 이상적입니다.

사용 사례

  • 반응형 레이아웃 만들기
  • 일관된 UI 간격 유지
  • 크로스 플랫폼 앱 개발
  • 여백 및 패딩 관리 간소화
  • 확장 가능한 디자인 시스템 만들기

주요 기능

  • 사전 정의된 간격 상수
  • 반응형 간격 지원
  • 플랫폼에 관계없는 설계
  • pub를 통한 간편한 통합
  • 깨끗하고 재사용 가능한 간격 값

적합한 대상

  • 디자인 시스템 구현
  • 크로스 플랫폼 플러터 앱
  • UI 일관성 중심 팀
  • 유지보수를 우선시하는 개발자
  • 확장 가능한 간격이 필요한 프로젝트

고려 사항

  • 사전 정의된 간격 스케일을 준수해야 합니다
  • 간격 값의 사용자 정의 제한
  • 일관된 디자인 언어를 사용하는 프로젝트에 가장 적합
  • 매우 동적 또는 변동하는 간격 요구 사항을 위한 것이 아님
  • 테마 또는 앱 구조의 올바른 구성에 따라 다릅니다

원본 README

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

logo

Spaces

Defining global spacing constants for building consistent and responsive apps.

Install

Add the dependency to your pubspec.yaml :

dependencies:
    spaces: <version>

Quick start

return MaterialApp(
    // Defining
    builder: (context, child) => Spacing(
        dataBuilder: (context) {
          final mediaQuery = MediaQuery.of(context);
          if (mediaQuery.size.width > 500) {
            return SpacingData.generate(30);
          }
          return SpacingData.generate(10);
        },
        child: child,
    ),
    home:Builder(builder: (context) {
        // Using
        final spacing = Spacing.of(context);
        return SpacedColumn.normal(
            padding: spacing.insets.all.semiBig,
            children: <Widget>[
                Text('hello'),
                Space.big(),
                Text('world'),
            ],
        );
      })
    ),
)

Usage

Configuring spacing

A Spacing widget should declare a global spacing configuration for your application.

return MaterialApp(
    builder: (context, child) => Spacing.fixed(
        data: SpacingData.generate(10.0), // This generates a set of spacing constants for your apps, from a base space of `10.0`.
        child: child,
    ),
    /// ...
)
Generate

By calling the Spacing.generate constructor, a set of constants are automatically generated from a single base value.

The generated values are :

  • extraSmall : value * 0.2
  • small : value * 0.4
  • semiSmall : value * 0.6
  • normal : value
  • semiBig : value * 1.5
  • big : value * 2.5
  • extraBig : value * 5.0
SpacingData.generate(10.0)
From spaces

If you want to define the various spacing values, you can use the

SpacingData.fromSpaces(
    extraSmall: 1.0,
    small: 2.0,
    semiSmall: 4.0,
    normal: 8.0,
    semiBig: 12.0,
    big: 20.0,
    extraBig: 100.0,
)

Responsive spacing

You can define the dataBuilder property of the Spacing constructor to generate a configuration from the given context.

Spacing(
    dataBuilder: (context) {
        final mediaQuery = MediaQuery.of(context);
        return SpacingData.generate(mediaQuery.size.width > 300.0 ? 20.0 : 10.0),
    },
    child: child,
)

Using constants

To access various spacing constants, simply use the Spacing.of(context) getter, or the context.spacing() extension method.

final spacing = Spacing.of(context);
// spacing.spaces.semiBig
Size variants

There are seven availables spacing constants : extraSmall, small, semiSmall, normal, semiBig, big, extraBig;

final spacing = Spacing.of(context);
return SizedBox(
    width: spacing.spaces.semiSmall,
);
Insets helpers

You have EdgeInsets presets available from <spacing>.insets.<selector>.<size>.

The available selectors are : all, horizontal, vertical, onlyLeft, onlyTop, onlyRight, onlyBottom, exceptLeft, exceptRight, exceptTop, exceptBottom.

final spacing = Spacing.of(context);
return Padding(
    padding: spacing.insets.exceptLeft.semiBig,
    child: Text('Hello'),
);

Widgets

Space

The Space widget uses gap under the hood to define a space in a Flex, Column, Row or Scrollable (such as ListView).

return Column(
    children: [
        Text('hello'),
        const Space.semiSmall(),
        Text('world'),
    ],
);
SpacedFlex / SpacedColumn / SpacedRow

Like Flex / Column / Row, but with additional padding and spaceBetween properties.

final spacing = Spacing.of(context);
return SpacedColumn.small(
    padding: spacing.insets.all.normal,
    children: [
        Text('hello'),
        Text('world'),
    ],
);

카테고리

의존성

의존성 목록 2 개

소스 저장소

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

아직 데이터가 없습니다.