颤振中FlatButton之间的空间

时间:2020-02-13 12:06:40

标签: flutter

enter image description here您好,我正在制作一个需要最大化和最小化屏幕的应用程序。但是,我想减少'A +'(即最大化屏幕)和'A-'(即最小化)之间的空间。我附上一张图片以便于更好地理解。谢谢。

代码如下:

return Scaffold(
      appBar: AppBar(
        title: Text(''),
        backgroundColor: Color(0xFF125688),
        actions: <Widget>[
           FlatButton(
                padding: EdgeInsets.all(0),
                onPressed: null,
                child: Text('A+',style: TextStyle(
                  fontSize: 22.0,fontWeight: FontWeight.bold,color: Colors.white
                ),)),

          FlatButton(
            padding: EdgeInsets.all(0),
            onPressed: null,
            child: Text('A-',style: TextStyle(
                fontSize: 15.0,fontWeight: FontWeight.bold,color: Colors.white
            ),),

          )

        ],
      ),

2 个答案:

答案 0 :(得分:1)

使用SizedBox

Scaffold(
      appBar: AppBar(
        title: Text(''),
        titleSpacing: 10,
        backgroundColor: Color(0xFF125688),
        actions: <Widget>[
           SizedBox(
             width: 30,
             child: FlatButton(
                padding: EdgeInsets.all(0),
                onPressed: null,
                child: Text('A+',style: TextStyle(
                  fontSize: 22.0,fontWeight: FontWeight.bold,color: Colors.white
                ),))),

          SizedBox(
             width: 30,
             child:FlatButton(
            padding: EdgeInsets.all(0),
            onPressed: null,
            child: Text('A-',style: TextStyle(
                fontSize: 15.0,fontWeight: FontWeight.bold,color: Colors.white
            ),),

          ))

        ],
      ))

答案 1 :(得分:0)

使用Cupertino Button代替FlatButton

CupertinoButton(
      minSize: double.minPositive,
      padding: EdgeInsets.zero,
      child: Text('A+'),
      onPressed: () {},
      pressedOpacity: 1.0,
    )