如何让浮动操作按钮固定在每个屏幕上?当我改变屏幕时,主屏幕上的浮动操作按钮消失了。有什么办法解决这个问题吗?
谢谢
发布于 2020-10-02 00:07:16
老实说,我不确定这是不是最好的方法,但是...你可以像下面这样定义一个类,并在你想要的每个屏幕中使用它作为你的小部件的父部件,
class MyParent extends StatelessWidget {
final Widget child;
const MyParent({Key key, this.child}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
child,
Positioned(
bottom: 0,
left: 0,
child: FloatingActionButton(
onPressed: (){},
),
)
],
);
}
}发布于 2020-10-02 00:12:08
您可以在这里定义所有的floastingAction按钮,如下所示
floatingActionButton:myFloatingActionButton()然后在新页面中创建一个小部件,如下所示
FloatingActionButton myFloatingActionButton({here you can add variables if you want a bit different things on every page}){
return FloatingActionButton(
child:Icon(Icons.add),//You can make any child,
//Any customization like colors and all
onPressed:(){}
);
}https://stackoverflow.com/questions/64159024
复制相似问题