【发布时间】:2021-09-25 05:13:52
【问题描述】:
如何在 Flutter/Dart 中以像素或任何其他单位设置 Positioned 小部件的左侧和顶部?
left 和 top 值的单位是什么?它们是百分比还是独立像素或其他什么?如果不是,它使用什么单位?
【问题讨论】:
-
它们是“逻辑像素”,更多信息请参见devicePixelRatio
标签: flutter dart flutter-positioned
如何在 Flutter/Dart 中以像素或任何其他单位设置 Positioned 小部件的左侧和顶部?
left 和 top 值的单位是什么?它们是百分比还是独立像素或其他什么?如果不是,它使用什么单位?
【问题讨论】:
标签: flutter dart flutter-positioned
例子:
Stack(
alignment: Alignment.center,
children: [
Container(
height: 200,
width: 200,
color: Colors.red,
),
// postion will be based on up Container Widget
// position top left
const Positioned(
left: 0,
top: 0,
child: CircleAvatar(
backgroundColor: Colors.blue,
),
),
// position bottom right
const Positioned(
bottom: 0,
right: 0,
child: CircleAvatar(
backgroundColor: Colors.blue,
),
),
],
),
如果你不给出任何立场。该位置将基于堆栈对齐。
【讨论】: