RflutterAlert:在另一行中制作一个按钮

时间:2020-09-04 19:36:34

标签: flutter line-breaks flutter-packages

大家好,我有这个简单的代码,其中包含3个按钮

void _showOptions (bill , context){
    Alert(
      context: context,
      type: AlertType.info,
      style: AlertStyle(titleStyle: Theme.of(context).textTheme.bodyText1),
      title: translator.currentLanguage == 'ar' ? 'الخيارات'
          : 'Options',
      buttons: [
        DialogButton(
          onPressed: (){
            Navigator.push(context,
                MaterialPageRoute(builder: (BuildContext context) =>
                    BillView(widget.userInformation , widget.userInformation, bill))
            );
          },
          color: Color(0xffff9900),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(translator.translate("view_bill"), style: TextStyle(color: Colors.white)),
              SizedBox(width: 5,),
              Icon(Icons.featured_play_list , color: Colors.white,)
            ],
          ),
        ),

        DialogButton(
        onPressed: (){
            Navigator.push(context,
                MaterialPageRoute(builder: (BuildContext context) =>
                    PurchasesEdit(widget.userInformation , widget.userInformation, bill))
            );
          },
          color: Colors.blue,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(translator.translate("edit"), style: TextStyle(color: Colors.white)),
                SizedBox(width: 5,),
                Icon(Icons.edit , color: Colors.white,)
              ],
            ),
          ),
        DialogButton(
          onPressed: (){
            return _deleteBill(bill['id'] ,  context);
          },
          color: Colors.red,
          child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(translator.translate("delete"), style: TextStyle(color: Colors.white)),
                SizedBox(width: 5,),
                Icon(Icons.delete_forever , color: Colors.white,)
              ],
            ),
          ),
      ],
    ).show();
  }

它工作正常,但三个按钮彼此相邻,我希望其中一个位于底部,另外两个位于顶部

现在的结果

查看-编辑-删除

我想要什么

编辑-删除

----查看------

我应该怎么做?

预先感谢

1 个答案:

答案 0 :(得分:0)

该库使用Row来渲染按钮,因此不可能创建一个

编辑-删除

----查看------

布局。我不使用该库,但您可能需要派生github项目,或仅使用一个DialogButton 并在其中创建子属性中的自定义按钮布局,或将按钮直接添加到content 。有很多解决方法,但我建议的主要方法是使用showGeneralDialog,确保可能需要一些时间来设置,但是您可以在其中更轻松地进行自定义布局