FLUTTER ECOSYSTEM

ijashuzain/the_responsive_builder

이 플러터 패키지는 다양한 화면 크기와 방향에 적응하는 반응형 플러터 애플리케이션을 구축하는 데 도움이 되는 유틸리티 세트를 제공합니다.

the_responsive_builder 프로젝트 이미지
Stars
4
Forks
1
최근 푸시(UTC)
2024. 10. 7.
프로젝트 상태
활성
Ijas Hussain GitHub avatar
GITHUB User

Ijas Hussain ↗

Zartek TechnologiesNilambur
언어Dart

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 3 개
  • flutter{"sdk":"flutter"}
  • flutter_test개발 의존성{"sdk":"flutter"}
  • flutter_lints개발 의존성^4.0.0

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

README 펼치기 / 접기

Pub

The Responsive Builder

This package provides a set of utilities to aid in building responsive Flutter applications that adapt to different screen sizes and orientations.

1. Setup

Firstly, add package to pubspec.yaml.

Then, wrap your main MaterialApp widget with the TheResponsiveBuilder

void main() => runApp(
  TheResponsiveBuilder(
    builder: (context, orientation, screenType) {
      return MaterialApp(
        //... your other MaterialApp properties
      );
    },
  ),
);
2. Usage of extensions

With the utilities set up, you can easily use the extensions provided:

- Height & Width
// This will set the height to 20% of the screen height
Container(height: 20.h, ...);

// This will set the width to 50% of the screen width
Container(width: 50.w, ...);
- Density Pixels & Scaled Pixels
// This uses a logarithmic formula to scale UI elements based on screen size and pixel density.
TextStyle(fontSize: 16.dp, ...);

// This scales the text size based on the user's font size settings.
TextStyle(fontSize: 16.sp, ...);
- Screen Type & Orientation
if (context.screenType == ScreenType.mobile) {
  // Build UI for mobile
} else {
  // Build UI for tablet
}

if (context.orientation == Orientation.portrait) {
  // Build UI for portrait mode
} else {
  // Build UI for landscape mode
}
- Lock & Unlock Screen Orientation
// Lock screen orientation to Portrait mode
context.lockToPortrait();

// Lock screen orientation to Landscape mode
context.lockToLandscape();

// Unlock screen orientation to automatic mode
context.unlockOrientation();