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

패키지 상세v0.1.1

dimensions_theme

Flutter 테마 내에서 앱 차원을 정의합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
148
좋아요
24
Pub 점수
150

패키지 설치

flutter pub add dimensions_theme

패키지 개요

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

dimensions_theme 패키지는 개발자가 Flutter 테마 내에서 앱 차원을 직접 정의하고 관리할 수 있게 해주며, 다양한 화면 크기에서 일관되고 반응형 UI 디자인을 가능하게 합니다. 차원 상수를 테마에 통합함으로써 외부 구성이나 하드코딩된 값에 의존하지 않고 레이아웃 조정을 간소화합니다. 이 접근 방식은 특히 복잡한 레이아웃을 가진 대규모 애플리케이션에서 유지보수성과 확장성을 향상시킵니다. 이 패키지는 모든 주요 플랫폼을 지원하여 크로스플랫폼 일관성을 보장합니다.

사용 사례

  • 반응형 레이아웃 관리
  • 중앙 집중형 차원 구성
  • 다중 플랫폼 UI 일관성
  • 테마 기반의 간격 및 크기
  • UI 확대 축소 간소화
  • 디자인 시스템의 무결성 유지

주요 기능

  • ThemeData에 차원 통합
  • 플랫폼에 관계없는 크기 지원
  • 테마 기반의 동적 차원을 활성화합니다
  • 하드코딩된 값에 대한 의존도를 줄입니다
  • 디자인 시스템 일치를 촉진합니다
  • 기존 테마와 원활하게 작동합니다

적합한 대상

  • 대규모 플러터 앱
  • 디자인 시스템 구현
  • 크로스 플랫폼 개발
  • UI 일관성을 우선시하는 팀
  • 테마 기반 스타일링을 사용하는 개발자

고려 사항

  • Flutter 테마 시스템에 대한 이해가 필요합니다
  • 사용자 정의 차원 로직을 위해 추가 설정이 필요할 수 있습니다
  • 테마 기반 차원 처리에 제한됨
  • 완전한 레이아웃 프레임워크가 아님
  • 반응형 레이아웃 전략과 함께 사용하는 것이 가장 좋습니다

원본 README

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

📏 dimensions_theme

dimensions_theme provides a theme extension to easily define and access app dimensions such as blank spaces, padding, border radius, and other dimensions within the Flutter theme.

Define your dimensions

// Uses tokens that best fit your project needs. You can also use multiple enums
enum Dimension {
  xlarge,
  large,
  medium,
  small,
  xsmall,
}

...

MaterialApp(
  theme: ThemeData(
    extensions: const [
      DimensionsTheme({
        Dimension.xlarge: 20,
        Dimension.large: 16,
        Dimension.medium: 12,
        Dimension.small: 8,
        Dimension.xsmall: 4,
      }),
    ],
  ),
);
Uses multiple enum for dimensions

The Dimensions theme extension supports using multiple enums as dimension tokens. This can be useful if you want to give different kinds of dimensions value their own enum.

enum Space {
  xlarge,
  large,
  medium,
  small,
  xsmall,
}

enum Padding {
  xlarge,
  large,
  medium,
  small,
  xsmall,

  screen,
}

...

MaterialApp(
  theme: ThemeData(
    extensions: const [
      DimensionsTheme({
        Space.xlarge: 20,
        Space.large: 16,
        Space.medium: 12,
        Space.small: 8,
        Space.xsmall: 4,

        Padding.xlarge: 20,
        Padding.large: 16,
        Padding.medium: 12,
        Padding.small: 8,
        Padding.xsmall: 4,
        Padding.screen: 20,
      }),
    ],
  ),
);

Consume dimensions values

You can access any dimension value using the get:

Dimensions.of(context).get(Dimension.small);

Additionally, this package provides helpers to make it easier to work with defined dimensions.

Padding

The padding context extension constructs EdgeInsets using the values defined in the dimensions theme for a given dimension token.

Padding(
  padding: context.padding.all(Dimension.small)
  child: ...
)

This extension provides counterparts to all EdgeInsets constructors but uses Dimension tokens instead of raw double values.

context.padding.all(Dimension.small)

context.padding.symmetric(
  horizontal: Dimension.medium,
  vertical: Dimensions.small,
)

context.padding.only(
  left: Dimension.large
  top: Dimension.large,
)
Blank spaces

The Space widget creates a SizedBox with the values defined in the dimensions theme for a given dimension token.

Column(
  children: [
    SomeWidget(),
    Space(Dimensions.small),
    SomeWidget(),
  ]
)

Alternatively, you can use the SpaceDimensionsMixin to construct Space widgets directly from your tokens:

/// Add `SpaceDimensionsMixin` to your dimension token responsible for spaces
enum Spaces with SpaceDimensionsMixin {
  large,
  medium
  small,
}

...

Column(
  children: [
    SomeWidget(),
    Spaces.small(),
    SomeWidget(),
  ]
)

All space widgets come with .w and .h constructors to restrict the blank space in one axis, respectively width and height.

Space.h(Dimensions.small)
Space.w(Dimensions.small)

Spaces.small.h()
Spaces.small.w()
Border radius

The radius context extension constructs Radius using the values defined in the dimensions theme for a given dimension token.

Container(
  decoration: BoxDecoration(
    borderRadius: BorderRadius.all(
      context.radius.circular(Dimensions.large),
    ),
  ),
)

This extension provides counterparts to all Radius constructors but uses Dimension tokens instead of raw double values.

context.radius.elliptical(Dimensions.large);
context.radius.circular(Dimensions.small, Dimensions.large);

The extension also provides a counterpart to BorderRadius.circular().

Container(
  decoration: BoxDecoration(
    borderRadius: borderRadius.circular(Dimensions.large),
  ),
)

카테고리

소스 저장소

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

아직 데이터가 없습니다.