
長話短說,我有一個堆疊,其中我有一個位于堆疊之外的影像。
body: Column(
children: [
Stack(
clipBehavior: Clip.none,
alignment: Alignment.center,
children: [
_positionedImage(),
],
),
_bodyContainer(),
],
容器:
Widget _bodyContainer() {
return Container(
width: MediaQuery.of(context).size.width,
height: 200,
decoration: BoxDecoration(
color: itsyBackground,
borderRadius: BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20)),
boxShadow: [BoxShadow(offset: Offset(0, 0), color: Colors.green, spreadRadius: 1, blurRadius: 1),],
),
);
}
我怎樣才能使圖片位于容器頂部?
uj5u.com熱心網友回復:
你在這里使用的方法是錯誤的。你不需要在這里列。您可以簡單地渲染一個堆疊,最底部的小部件應首先放置在堆疊子項中。
https://medium.com/flutter-community/a-deep-dive-into-stack-in-flutter-3264619b3a77
一個例子:
Stack(
clipBehavior: Clip.none,
alignment: Alignment.center,
children: [
Container(
width: MediaQuery.of(context).size.width,
height: 200,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20)),
boxShadow: [
BoxShadow(
offset: Offset(0, 0),
color: Colors.green,
spreadRadius: 1,
blurRadius: 1),
],
),
),
Positioned(
top: -10,
child: Image.network(
'https://static.toiimg.com/thumb/msid-31346158,width-748,height-
499,resizemode=4,imgsize-114461/.jpg',
width: 100,
),
),
],
),
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/412705.html
標籤:
上一篇:將變數設定為導航器路由顫動
下一篇:水平串列視圖的一部分不在基線上
