首页 > 解决方案 > 如何减少 raisebutton.icon 小部件中图标和文本之间的空间?

问题描述

我想减少凸起按钮内的图标和文本之间存在的空间

在此处输入图像描述

这是我试图做的:

            RaisedButton.icon(onPressed: (){
                    (product.hasAbonnement=false) ?
                    Navigator.push(context,
              MaterialPageRoute(builder: (context) => ProductDetailPage(
              product: product,
              viewModel: widget.viewModel,),
      ))
        :
          Navigator.push(context,
              MaterialPageRoute(builder: (context) => SubcriptionDetailPage(
              product: product,
              viewModel: widget.viewModel,),
      ));

      }, icon: Icon(Icons.add,color: Colors.white), label:Text('S\'abonner',
      style:TextStyle(color:Colors.white,
      )
     ,),
     clipBehavior: Clip.antiAlias,
     shape: RoundedRectangleBorder(
    borderRadius: BorderRadius.circular(18.0),
    ),
    color:mmpataColorBlue,
      ),

标签: flutter

解决方案


这是解决方案,因为Hiwa Jalal给出了正确的答案,只需要一点操作。干得好:

Center(
   child: RaisedButton(
     color: Colors.blue,
     shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.circular(18.0),
     ),
     child: Row(
       mainAxisSize: MainAxisSize.min,
       children: <Widget>[
         Icon(Icons.add, color: Colors.white), 
         Text('S\'abonner', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold))
       ]
     ),
     onPressed: () {}
   )
)

输出:

结果截图


推荐阅读