我想将图标放置在父边界之外并使其具有响应性(相对于父级的高度)。
Stack
使用和小部件将图标放置在父边界之外是没有问题的Positioned
。
但是让它有响应是有问题的。
因此,如果容器高度减小,那么图标大小也应该减小。
Container(
decoration: BoxDecoration(
border: Border.all(
color: Color(0xff2577ff),
width: 5.0,
),
borderRadius: BorderRadius.all(
Radius.circular(15.0),
),
),
width: 200.0,
height: 80.0,
child: Stack(
clipBehavior: Clip.none,
children: [
Center(
child: Text('Text'),
),
Positioned( // <-- doesn't work
top: -20.0, // <-- how to make it also relative to parent's height parameter?
right: -20.0, // <-- how to make it also relative to parent's height parameter?
child: FractionallySizedBox( // <-- doesn't work
heightFactor: 0.5,
child: Image.network('https://i.stack.imgur.com/dOkkG.png'),
)
)
],
),
)
我试图制作一些样品但没有成功。我真的不知道如何用 Flutter 实现这样的逻辑,也找不到任何可靠的例子。