可以给这个按钮移动到屏幕右下角并缩小大小到原来的百分之20 floatingActionButton Stack children GestureDetector onTap
将上述代码修改为:
floatingActionButton: Positioned( bottom: 16.0, right: 16.0, child: GestureDetector( onTap: () { hItems(DateTime.now()); setState(() { print('回到今天'); _calendarAgendaControllerAppBar.goToDay(DateTime.now()); }); }, child: Container( width: MediaQuery.of(context).size.width * 0.2, height: MediaQuery.of(context).size.width * 0.2, child: RiveAnimation.asset( 'assets/birds.riv', animations: const [ 'Fly2', ], ), ), ), ),
解释一下修改内容:
- 使用 Positioned 组件将按钮定位到屏幕右下角;
- 设置 bottom 和 right 属性,分别表示距离屏幕底部和右侧的距离;
- 将 GestureDetector 和 Container 组件包裹在 Positioned 组件中;
- 设置 Container 的宽度和高度为屏幕宽度的百分之二十
原文地址: https://www.cveoy.top/t/topic/fly1 著作权归作者所有。请勿转载和采集!