首页 > 解决方案 > 为什么我不能在颤动中更改凸起按钮的宽度和高度属性?

问题描述

我正在开发这个简单的应用程序,我似乎无法更改凸起按钮的宽度和高度属性,我也尝试使用平面按钮,但它也不起作用。这是一个屏幕截图

Row (mainAxisAlignment: MainAxisAlignment.spaceEvenly,
           children: <Widget>[
             RaisedButton(
               height: 20,
               color: Colors.green,
               onPressed: () {
                 setState(() { });
               },

错误消息:未定义命名参数“高度”。尝试将名称更正为现有命名参数的名称,或使用名称“height”定义命名参数。

标签: flutterdart

解决方案


你应该用其他通过他的约束的小部件包装你的 Raised Button,比如 Container

Container(
  width: 200,
  height: 50,
  child: RaisedButton(
    onPressed: this.action,
    color: Colors.blue,
    child: Text('Title', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
  ),
)

推荐阅读