文章目录
Flutter屏幕适配
一、Flutter中的单位
1.1. 点-points
在刚开始,所有的图形位置都由坐标点指定。
点事抽象的单位,它们只在逻辑坐标系上有意义。
- 在进行Flutter开发时,我们通常不需要传入尺寸的单位,就像下边这种。
Scaffold(
appBar: AppBar(
title: Text("首页"),
),
body: Center(
child: Container(
width: 400,
height: 400,
color: Colors.red,
alignment: Alignment.center,
child: Text("Hello World", style: TextStyle(fontSize: 20),),
),
),
);
没有传入单位,此时其实用的是单位是pt,也就是point,点的概念。
- 拿iphone6 举例子常说iPhone6 的尺寸是 375x667 这个就是点的概念
1.2. 像素-pixels
我们说iPhone6 的物理像素 ,有的也叫分辨率 是 750x1334 ,这个指的是像素pixel,单位是px,UI设计出的图,单位就可能是px值。
1.3. 设备像素比-devicePixelRatio
我们说iPhone6 的 devicePixelRatio 等于2,这是怎么来的呢?
d e v i c e P i