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

패키지 상세v1.0.0+4

sized_context

컨텍스트를 통해 MediaQuery 크기 정보에 직접 액세스할 수 있으며, 크기 및 레이아웃을 위한 보조 메서드도 추가합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
60
좋아요
195
Pub 점수
160

패키지 설치

flutter pub add sized_context

패키지 개요

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

sized_context 패키지는 컨텍스트를 통해 MediaQuery의 크기 정보에 직접 액세스할 수 있도록 하여 반응형 UI 개발을 단순화합니다. 이 패키지는 화면 메트릭을 기반으로 크기, 간격 및 레이아웃 차원을 계산하기 위한 유용한 보조 메서드를 BuildContext에 확장합니다. 이로 인해 위젯 트리 전체에서 MediaQuery.of(context)를 반복적으로 호출할 필요가 사라집니다. 다양한 디바이스 크기와 방향에 맞춰 적응 가능한 레이아웃을 구축하는 데 이상적입니다.

사용 사례

  • 반응형 레이아웃 디자인
  • 크로스 플랫폼 UI 적응
  • 동적 위젯 크기 조정
  • MediaQuery 사용 간소화
  • 장치 간 일관된 간격

주요 기능

  • 직접적인 맥락 기반 크기 조정
  • 내장된 크기 계산 도구
  • 반복 코드를 줄입니다
  • 모든 플러터 플랫폼을 지원합니다
  • 기존 위젯과의 간편한 통합

적합한 대상

  • 반응형 앱을 개발하는 개발자
  • UI 일관성을 우선시하는 팀
  • 다중 플랫폼을 대상으로 하는 프로젝트
  • 동적 레이아웃을 요구하는 앱

고려 사항

  • 컨텍스트 액세스가 필요합니다
  • 과도하게 사용할 경우 빌드 복잡성을 증가시킬 수 있습니다
  • 간단한 정적 레이아웃에는 필요하지 않음
  • 크기 관련 기능에 한정
  • 다른 레이아웃 패키지와 함께 사용하는 것이 가장 좋습니다

원본 README

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

✥ Sized Context - Easy responsive sizing

With this extension package you can easily access the MediaQuery sizing info directly on the build context:

Size size = context.sizePx;

It also provides additional convenience methods like landscape state, diagonal screen size, inch-based measurements, screen type and percentage values:

bool isLandscape = context.isLandscape; //Instead of: MediaQuery.of(context).orientation == Orientation.landscape
bool isTablet = context.diagonalInches >= 7; //Get physical device size in inches 
bool useSingleColumn = context.widthPx < 400; //Access .width and .height directly, no need to go through .size
double sidePadding = context.widthPercent(0.1); //Use percentages of width or height for sizing

🔨 Installation

dependencies:
  sized_context: ^1.0.0+1
⚙ Import
import 'package:sized_context/sized_context.dart';

🕹️ Usage

bool isLandscape = context.isLandscape;
//PIXELS
Size size = context.sizePx;
double width = context.widthPx;
double height = context.heightPx;
double diagonalPx = context.diagonalPx;
//INCHES
Size sizeInInches = context.sizeInches;
double widthInInches = context.widthInches;
double heightInInches = context.heightInches;
double diagonalInInches = context.diagonalInches;
//PERCENTAGE
double widthPercent = context.widthPct(.1);
double heightPercent = context.heightPct(.25);

For convenience you can also access the MediaQueryData object directly, to get any other methods or properties:

EdgeInsets padding = context.mq.padding;
Size safeSize = context.mq.removePadding();

🐞 Bugs/Requests

If you encounter any problems please open an issue. If you feel the library is missing a feature, please raise a ticket on Github and we'll look into it. Pull request are welcome.

👏 Thanks

  • Thanks to reddit user der_kobold for the idea to turn this into an extension!

📃 License

MIT License

카테고리

의존성

의존성 목록 1 개

소스 저장소

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