【发布时间】:2018-11-19 08:49:15
【问题描述】:
【问题讨论】:
-
将内容放入SingleChildScrollView
-
但是我需要两个部分中间的“OR”按钮和屏幕底部的提交按钮,所以使用了堆栈。请看代码
-
然后将 Stack 放入滚动视图中。
-
这不起作用,先生
【问题讨论】:
您在错误的地方使用了堆栈。 您需要在上部(scanPortion)小部件中使用堆栈。 CircleAvatar 应该与 scanPortion 重叠并使溢出可见。这样,CircleAvatar 将被卡在 scanPortion 上并随之滚动。
从当前位置移除 CircleAvatar 并将 scanPortion 更改为以下内容:
var scanPortion = new Stack(
children: <Widget>[
new Container(
height: MediaQuery.of(context).size.height / 2 - 40,
width: MediaQuery.of(context).size.width,
color: new Color(0xFF4A4A4C).withOpacity(0.5),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
qrCode,
SizedBox(
height: 10.0,
),
new RaisedButton.icon(
color: Colors.blueAccent,
textColor: Colors.white,
shape: new RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(30.0)),
onPressed: () async {},
icon: new Icon(
Icons.camera_alt,
color: Colors.white,
),
label: Text('Scan'),
)
],
),
),
Positioned(
top: (MediaQuery.of(context).size.height / 2 - 40.0) - 20.0,
left: (MediaQuery.of(context).size.width) / 2 - 20.0,
child: Center(
child: CircleAvatar(
backgroundColor: Colors.pink,
child: Text('OR'),
radius: 20.0,
),
),
),
],
overflow: Overflow.visible,
);
稍后小心删除旧堆栈,因为它没有任何用处。
【讨论】:
Column( Flexible( ListView( scanPortion manualEntryPortion ) ) Container( FlatButton() ) )