Flutter 颤振溢出定位按钮不可单击
我有一个堆栈小部件作为定位小部件的子对象,如下所示:Flutter 颤振溢出定位按钮不可单击,flutter,dart,Flutter,Dart,我有一个堆栈小部件作为定位小部件的子对象,如下所示: Stack( overflow: Overflow.visible, children: [ Container( width: 150, height: 150, ), Positioned( child: FloatingActionButton(
Stack(
overflow: Overflow.visible,
children: [
Container(
width: 150,
height: 150,
),
Positioned(
child: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () {
print('FAB tapped!');
},
backgroundColor: Colors.blueGrey,
),
right: 0,
left: 0,
bottom: -26,
),
],
),
放置在容器外部的晶圆厂部分不可点击,解决方案是什么?
下面是一个屏幕截图:
试试这个:
Stack(
overflow: Overflow.visible,
children: [
Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>
[
Container(width: 150, height: 150, color: Colors.yellow),
Container(width: 150, height: 28, color: Colors.transparent),
],
),
Positioned(
child: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () {
print('FAB tapped!');
},
backgroundColor: Colors.blueGrey,
),
right: 0,
left: 0,
bottom: 0,
),
],
)
堆栈(
溢出:溢出。可见,
儿童:[
纵队(
mainAxisSize:mainAxisSize.min,
儿童:
[
容器(宽度:150,高度:150,颜色:颜色。黄色),
容器(宽度:150,高度:28,颜色:彩色,透明),
],
),
定位(
子:浮动操作按钮(
子:图标(Icons.add),
已按下:(){
打印('FAB tapped!');
},
背景颜色:颜色。蓝灰色,
),
右:0,,
左:0,,
底部:0,
),
],
)
若你们想让按钮保持可点击状态,你们应该把它放在堆栈里面
Container(
width: 150,
height: 180,
child: Stack(
children: [
Container(
width: double.infinity,
height: 150,
child: Image.asset('assets/images/image.jpg', fit: BoxFit.cover,)
),
Container(
alignment: Alignment.bottomCenter,
child: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () {
print('FAB tapped!');
},
backgroundColor: Colors.blueGrey,
),
),
],
),
),
Fab按钮是不可点击的,因为它在堆栈外呈现,正如您给定的-ve底部一样,理想情况下,您应该有父容器,在它里面有您应该呈现的所有堆栈小部件。
这里我使用了硬编码的值,但您应该根据需要使用媒体查询
如:
Container(
width: MediaQuery.of(context).size.width * 0.3,
height: MediaQuery.of(context).size.height * 0.3,
child: Stack(
children: [
Container(
width: double.infinity,
height: MediaQuery.of(context).size.height * 0.26,
child: Image.asset('assets/images/jitesh.jpg', fit: BoxFit.cover,)
),
Container(
alignment: Alignment.bottomCenter,
child: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () {
print('FAB tapped!');
},
backgroundColor: Colors.blueGrey,
),
),
],
),
),
通过这个检查工作环境