作者热门文章
- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
如何在 Flutter 中创建一个 float 按钮并在按钮按下时为不同的选项设置动画?我正在尝试制作如下内容:
当我尝试添加多个 float 按钮时,出现“argument for the name floating button action has already been specified
”错误
class MyBills extends StatelessWidget {
MyBills({Key key}) : super(key: key);
//@override
//MyBillsPageState createState() => MyBillsPageState();
@override
Widget build(BuildContext context) {
return new Scaffold(
body: ListView.builder(
itemCount: 20,
itemBuilder: (context, index) {
return new Container(height: 100, child: BillItem());
}
),
floatingActionButton: new FloatingActionButton(
child: new Icon(Icons.add),
heroTag: 1,
onPressed: _addAttachment
),
floatingActionButton: new FloatingActionButton(
child: new Icon(Icons.camera),
heroTag: 2,
onPressed: _cameraAttachment
),
);
}
或动画 float 选项 like this
最佳答案
给每个 FloatingActionButton
一个唯一的 heroTag
标签,你就可以开始了。
floatingActionButton: FloatingActionButton(
heroTag: 0, // you can use any object here
),
您的解决方案:
@override
Widget build(BuildContext context) {
return new Scaffold(
body: Stack(
alignment: Alignment.bottomRight,
children: <Widget>[
ListView.builder(
itemCount: 20,
itemBuilder: (context, index) {
return new Container(height: 100, child: BillItem());
}
),
Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new FloatingActionButton(child: new Icon(Icons.add), heroTag: 1, onPressed: _addAttachment),
new FloatingActionButton(child: new Icon(Icons.camera), heroTag: 2, onPressed: _cameraAttachment),
],
),
],
),
);
}
关于flutter - 如何在flutter中为附件创建一个 float 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54395652/
我是一名优秀的程序员,十分优秀!