MediaQueryPreview는 다양한 기기, 화면 크기, 밝기 수준 및 텍스트 확대 비율에서 실시간 UI 미리보기를 가능하게 하는 개발 도구입니다. 실제 장치에 배포하지 않고도 앱이 다양한 구성에서 어떻게 보일지 시각적으로 확인할 수 있도록 도와줍니다. 이 패키지는 사용자 정의 기기 정의를 지원하며, 생산 환경이 아닌 개발 워크플로우 전용으로 설계되었습니다. Flutter의 MediaQuery와 원활하게 통합되어 디자인 및 테스트 단계에서 빠른 반복을 가능하게 합니다.
사용 사례
반응형 레이아웃 테스트
다른 장치 화면 시뮬레이션
접근성 설정 조정
다양한 조건 하에서 UI 동작 검증
UI 개발 워크플로우 간소화
주요 기능
사용자 정의 장치 구성 지원
화면 크기 변경 실시간 미리보기
조절 가능한 밝기 및 텍스트 크기
크로스 플랫폼 호환성
기존 플러터 프로젝트와의 간편한 통합
적합한 대상
디자인 단계의 플러터 개발자
반응형 UI에 집중하는 팀
접근성 테스트
빠른 프로토타이핑
고려 사항
생산 사용을 위한 것이 아님
사용자 정의 장치를 위해 수동 설정이 필요합니다
개발 환경에 한정
강한 사용 시 성능에 영향을 미칠 수 있습니다
실기기 테스트를 대체하지 않습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Have you ever experienced your UI breaking when the font size is too large or the screen size of the device is small? Checking for these issues can be a hassle.
This package allows you to preview how your implemented UI will appear on various devices with different screen sizes, text scales, and brightness.
If you are using riverpod, you can do the following.
// Initialize Providerfinal container = ProviderContainer();
final previewDevices = [
[
PreviewDevice.iPhone5_5inch(
textScaleFactor: 0.5,
),
PreviewDevice.iPhone5_5inch(),
PreviewDevice.iPhone5_5inch(
brightness: Brightness.dark,
),
PreviewDevice.iPhone5_5inch(
textScaleFactor: 1.5,
),
],
[
PreviewDevice.iPhone6_7inch(
textScaleFactor: 0.5,
),
PreviewDevice.iPhone6_7inch(),
PreviewDevice.iPhone6_7inch(
brightness: Brightness.dark,
),
PreviewDevice.iPhone6_7inch(
textScaleFactor: 1.5,
),
],
[
PreviewDevice.android6_7inch(
textScaleFactor: 0.5,
),
PreviewDevice.android6_7inch(),
PreviewDevice.android6_7inch(
brightness: Brightness.dark,
),
PreviewDevice.android6_7inch(
textScaleFactor: 1.5,
),
]
];
runApp(
MediaQueryPreview(
previewDevices: previewDevices,
builder: (_, previewDevice) {
// If you want to change the theme based on the targetPlatform,// you can get the targetPlatform from [previewDevice.targetPlatform].returnUncontrolledProviderScope(
container: container,
child: constMyApp(),
);
},
),
);
If you are not using riverpod, it is even simpler.
runApp(
MediaQueryPreview(
previewDevices: previewDevices,
builder: (_, previewDevice) {
// If you want to change the theme based on the targetPlatform,// you can get the targetPlatform from [previewDevice.targetPlatform].returnconstMyApp();
},
),
);
Attention
It is recommended to use this package only development. Please do not use it in production.
This package allows you to display multiple instances of the Widget you implemented at the same time, which may lead to poor performance or issues with state management.
If you manage GlobalKey with global variables, they will be shared across each preview, which can lead to errors or unintended behavior. Since the widget trees of each preview are independent, it is recommended to generate a separate GlobalKey for each tree.
Future
If you have Apple Vision Pro, you can use it as a "Designed for iPad" app. This is the future!