Flutter 如何为颤振中的附件创建浮动按钮

Flutter 如何为颤振中的附件创建浮动按钮,flutter,flutter-layout,Flutter,Flutter Layout,如何创建一个浮动按钮,并在其按钮按下时设置不同选项的动画?我正在尝试制作如下内容: 当我尝试添加多个浮动按钮时,我得到的“名称浮动按钮操作的参数已被指定””错误 class MyBills extends StatelessWidget { MyBills({Key key}) : super(key: key); //@override //MyBillsPageState createState() => MyBillsPageState(); @overri

如何创建一个浮动按钮,并在其按钮按下时设置不同选项的动画?我正在尝试制作如下内容:

当我尝试添加多个浮动按钮时,我得到的“
名称浮动按钮操作的参数已被指定”
”错误

    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
      ),
    );
  }

或者设置浮动选项的动画

给每个
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),
          ],
        ),
      ],
    ),
  );
}
@覆盖
小部件构建(构建上下文){
归还新脚手架(
主体:堆栈(
对齐:对齐。右下角,
儿童:[
ListView.builder(
物品计数:20,
itemBuilder:(上下文,索引){
返回新容器(高度:100,子项:BillItem());
}
),
纵队(
mainAxisSize:mainAxisSize.min,
儿童:[
新建FloatingActionButton(子项:新建图标(Icons.add),heroTag:1,onPressed:\u addAttachment),
新浮动操作按钮(子项:新图标(Icons.camera),heroTag:2,ON按下:_camera附件),
],
),
],
),
);
}

给每个
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),
          ],
        ),
      ],
    ),
  );
}
@覆盖
小部件构建(构建上下文){
归还新脚手架(
主体:堆栈(
对齐:对齐。右下角,
儿童:[
ListView.builder(
物品计数:20,
itemBuilder:(上下文,索引){
返回新容器(高度:100,子项:BillItem());
}
),
纵队(
mainAxisSize:mainAxisSize.min,
儿童:[
新建FloatingActionButton(子项:新建图标(Icons.add),heroTag:1,onPressed:\u addAttachment),
新浮动操作按钮(子项:新图标(Icons.camera),heroTag:2,ON按下:_camera附件),
],
),
],
),
);
}

我给出了不同的heroTag,但仍然得到相同的错误。我在问题中进行了编辑。看看我在哪里尝试添加有效的浮点。。但是如何设置动画和显示不同的选项呢?其他浮动按钮应在初始负载时隐藏view@DeepakThakur请将此作为一个单独的问题提问。别忘了投票并接受这个答案。谢谢:)但我问题的第一部分是只设置浮动按钮的动画和显示。我给了不同的heroTag,但我仍然得到相同的错误。我在问题中做了编辑。看看我在哪里尝试添加有效的浮点。。但是如何设置动画和显示不同的选项呢?其他浮动按钮应在初始负载时隐藏view@DeepakThakur请将此作为一个单独的问题提问。别忘了投票并接受这个答案。谢谢:)但我问题的第一部分是设置浮动按钮的动画和显示。这是你想要的吗?这里还有一个不用包装的。是的。。明白了!你想要的是什么?这里还有一个不用包装的。是的。。明白了!