为什么不改变按钮的高度和宽度

时间:2019-12-18 14:04:55

标签: flutter

InkWell(
  borderRadius: BorderRadius.all(Radius.circular(5)),
    onTap: () {},
    child: SizedBox(
      height: 25,
      width: screenWidth *65,
      child: Container(
        color: Colors.blueAccent,
        child: Text(
          'Confirm',
           textAlign: TextAlign.center,
           style: TextStyle(
             fontSize: 15,
             color: Color(0xff000000),
             fontWeight: FontWeight.w500),
           ),
         ),
       ),
      ),

2 个答案:

答案 0 :(得分:0)

这是您要寻找的吗?

Container(
  padding: EdgeInsets.all(6),
  width: double.infinity,
  child: FlatButton(
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.all(Radius.circular(5))
    ),
    color: Colors.blueAccent,
    onPressed: () => print('pressed'),
    child: Text('Confirm',
      style: TextStyle(
        fontSize: 15,
        color: Color(0xff000000),
        fontWeight: FontWeight.w500
      ),
    )
  ),
),

答案 1 :(得分:0)

删除SizedBox小部件,因为当您已经在使用容器时,无论如何在当前小部件树中都没有问题

并在height小部件中使用这些widthcontainer参数

尝试

InkWell(
    borderRadius: BorderRadius.all(Radius.circular(5)),
    onTap: () {},
      child: Container(
        height: 25,
        width: screenWidth *65,    
        color: Colors.blueAccent,
        child: Text(
          'Confirm',
           textAlign: TextAlign.center,
           style: TextStyle(
             fontSize: 15,
             color: Color(0xff000000),
             fontWeight: FontWeight.w500),
           ),
         ),
     ),