【发布时间】:2022-01-12 06:25:57
【问题描述】:
我想在屏幕截图中实现以下 UI,并通过以下代码在两部不同的手机上实现。但同样不适用于许多其他设备。有没有办法处理CircularProgressIndicator 的大小(目前我正在使用Transform.scale(),它没有给我一般的结果),以便它适合堆栈内的兄弟容器?
编辑:
使用CircularProgressIndicator的原因是为了显示进度。
Widget build(BuildContext context) {
final mediaq = MediaQuery.of(context).size;
return Stack(alignment: Alignment.center, children: [
Transform.scale(
scale: mediaq.width <= 360 ? 2.35 : 2.70,
child: const CircularProgressIndicator(
backgroundColor: Colors.white,
color: Colors.orange,
strokeWidth: .75,
value: 1,
),
),
Container(
decoration: const BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
colors: [Colors.red, Colors.orange],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.transparent,
fixedSize: Size(mediaq.width * .24, mediaq.height * .12),
shape: const CircleBorder(side: BorderSide.none),
),
onPressed: () {},
child: const Text("child")),
),
]);
}
【问题讨论】:
-
能否附上其他设备的截图?还有设备信息。
-
@FaiiziiAwan 上面截图的设备是像素 4a。宽度为 392.72,高度为 753.45。
-
您说在其他设备上也无法正常工作。那些设备是什么?结果是什么?它与期望的结果有何不同?
-
@FaiiziiAwan iPhone SE 例如不显示任何内容。宽:320,高:568。