当前位置:网站首页>Flutter库推荐Sizer 可帮助您轻松创建响应式 UI
Flutter库推荐Sizer 可帮助您轻松创建响应式 UI
2022-06-12 22:23:00 【InfoQ】
sizer


安装️
dependencies:
...
sizer: ^2.0.15
参数️
.h- 返回基于设备计算的高度
.w- 根据设备返回计算出的宽度
.sp- 返回基于设备计算的 sp
SizerUtil.orientation- 用于屏幕方向纵向或横向
SizerUtil.deviceType- 适用于设备类型手机或平板电脑
用法
将以下导入添加到您的 Dart 代码中:
import 'package:sizer/sizer.dart';
用 ResponsiveSizer 小部件包装 MaterialApp
Sizer(
builder: (context, orientation, deviceType) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Sizer',
theme: ThemeData.light(),
home: homePage(),
);
},
)
import 'package:sizer/sizer.dart';
小部件大小
Container(
width: 20.w, //It will take a 20% of screen width
height:30.h //It will take a 30% of screen height
)
填充
Padding(
padding: EdgeInsets.symmetric(vertical: 5.h, horizontal: 3.h),
child: Container(),
);
字体大小
Text(
'Sizer',style: TextStyle(fontSize: 15.sp),
);
方形小部件*
Container(
width: 30.h, //It will take a 30% of screen height
height: 30.h, //It will take a 30% of screen height
);
方向
Device.orientation == Orientation.portrait
? Container( // Widget for Portrait
width: 100.w,
height: 20.5.h,
)
: Container( // Widget for Landscape
width: 100.w,
height: 12.5.h,
)
设备类型
SizerUtil.deviceTypeSizerUtil.deviceType == DeviceType.mobile
? Container( // Widget for Mobile
width: 100.w,
height: 20.5.h,
)
: Container( // Widget for Tablet
width: 100.w,
height: 12.5.h,
)
建议
注意
sizernumber.hnumber.wnumber.sp10.hDeviceimport 'package:sizer/sizer.dart';
边栏推荐
- Plusieurs camarades de classe de Tsinghua sont partis...
- A 42 year old senior executive of a large factory reminds people aged 30-39 that these six habits that make you stronger should be developed as soon as possible
- Database daily question --- day 10: combine two tables
- About the solution to "the application cannot start normally 0xc00000022" after qt5.15.2 is installed and qtcreator is started
- 年薪50万是一条线,年薪100万又是一条线…...
- ShardingSphere-proxy-5.0.0部署之分表实现(一)
- 【数据分析】基于 kmeans实现数据聚类分组含Matlab源码
- [probability theory and mathematical statistics] final review: formula summary and simple examples (end)
- leetcodeSQL:574. Elected
- JVM foundation - > talk about class loader two parent delegation model
猜你喜欢

Kotlin collaboration process - flow

Implementation of master-slave replication and master-master replication for MySQL and MariaDB databases

Su embedded training day13 - file IO

基于51单片机的酒精检测仪

年薪50万是一条线,年薪100万又是一条线…...

(downloadable) Research Report on the development and utilization of government data (2021), a glimpse of the development of Government Office

MySQL case when then function use

Modstartcms modular station building system v3.3.0 component function upgrade, event triggering enhancement

C语言:如何给全局变量起一个别名?

Design a MySQL table for message queue to store message data
随机推荐
June training (day 11) - matrix
Use group_ Dplyr issues when using group_ by(multiple variables)
JVM foundation - what is the process of loading > objects into the JVM, and then clearing them by GC?
[leetcode] the k-largest element in the array
Yyds dry goods inventory solution sword finger offer: the first non repeated character in the character stream
[proteus simulation] simple digital tube timer clock
JVM foundation > CMS garbage collector
Is it safe to open an account in flush? How to open an account online to buy stocks
JVM Basics - > how to troubleshoot JVM problems in your project
设计消息队列存储消息数据的 MySQL 表格
【LeetCode】300.最长上升子序列
【LeetCode】102. 二叉树的层序遍历
C # reading table data in word
【概率论与数理统计】期末复习抱佛脚:公式总结与简单例题(完结)
Qt Quick 3D学习:鼠标拾取物体
Hostvars in ansible
Unity commonly used 3D mathematical calculation
Can tonghuashun open an account? Is it safe to open an account in tonghuashun? How to open a securities account
Is there any risk in opening a securities account? How to open an account safely?
(downloadable) Research Report on the development and utilization of government data (2021), a glimpse of the development of Government Office