[英]how can I make this stack widget in flutter?
by default stack widget childs are positioned on the top left corner of the screen.默认情况下,堆栈小部件的子元素位于屏幕的左上角。 first child is on the bottom of the stack and anything comes after it is going to be above it.
第一个孩子在堆栈的底部,任何在它之后的东西都会在它上面。 the solution is simple use Positioned widget to position the stack child widgets anywhere you want on the screen.
解决方案很简单,使用 Positioned 小部件到 position 在屏幕上任何您想要的位置堆叠子小部件。 this code should do the trick for you.
这段代码应该可以为您解决问题。 I dont know if its the best approach for your case but it works
我不知道它是否适合您的情况,但它有效
Stack(
fit: StackFit.expand,
children: [
Container(
width: double.infinity,
height: 220,
color: Colors.indigo,
child: const Text(
'consider this is an Image',
textAlign: TextAlign.center,
),
),
Positioned(
top: 180,
width: 395,
child: Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topRight: Radius.circular(32),
topLeft: Radius.circular(32),
),
),
height: 600,
width: 395,
child: Column(
children: const [
// ** Your child widgets**
],
),
),
),
],
),
You can use stack
for overlapping each other and than inside that stack you can use DraggableScrollableSheet class
for that scrollable white
card.您可以使用
stack
相互重叠,而不是在该堆栈内部您可以使用DraggableScrollableSheet class
作为scrollable white
卡。
Stack(
fit: StackFit.expand,
children: [
Container(
Image(),
),
DraggableScrollableSheet(
builder: (BuildContext context, ScrollController scrollController){
return Container(),
}
),
),
],
),
You can try something like this你可以尝试这样的事情
Stack(
children: <Widget>[
Container(
child: Image.asset(url),
),
),
Container(
child: Text('Show text here')
),
]),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.