[英]Flutter: Is there a way to add a floating action button inside a container?
Is there a way to add a floating action button inside a container?有没有办法在容器内添加浮动操作按钮? Or at least achieve a similar effect?或者至少达到类似的效果?
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
@override
Widget build(BuildContext context) {
return Container(
child: Padding(
child: Column(
children: <Widget>[
Text('Hello'),
SizedBox(height: 30),
Expanded(
child: Container(
child: TaskList(),
),
)
],
),
),
);
}
}
Ps.附言。 I can't use scaffold for a few reasons so don't suggest that.由于某些原因,我不能使用脚手架,所以不建议这样做。
Yes, you can utilize child
property of Container
是的,您可以利用Container
child
属性
Container (
child: FloatingActionButton()
)
You can use Container in floatingActionButton:
after Flutter 2.0您可以在floatingActionButton:
Flutter 2.0 之后
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: GestureDetector(
onTap: (){},
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
margin: const EdgeInsets.symmetric(horizontal:15),
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: AppColors.accentColor2,
borderRadius: BorderRadius.circular(8)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Text('Attendence Summary',style: TextStyle(fontWeight: FontWeight.w300,color: Colors.white,fontSize: 12),),
Text('Present : 20 | Absentees : 10',style: TextStyle(color: Colors.white,fontSize: 14),),
],
),
const Text('Review',style: TextStyle(color: Colors.white),)
],
),
),
],
),
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.