【问题标题】:Flutter RaisedButton Hightlightelevation delayFlutter RaisedButton Hightlightelevation delay
【发布时间】:2020-11-02 19:15:06
【问题描述】:

我在 Flutter 中创建了以下 RaisedButton:

问题是,当您按住按钮大约 1 秒钟时,按钮的 highlightElevation 会触发,此时我的图像显示在按钮的左侧,但是当我删除图像时,它会按预期工作。 有没有办法在保留图像的同时解决这个问题?

这是我的代码:

Widget systems(String systemName, String systemTitle, Image img) {
return Center(child:
Container( width:width-20,height:110,child:
Column( children: <Widget>[
SizedBox(height: 10),
RaisedButton( elevation: 10,splashColor: Colors.transparent,highlightElevation: 0, shape: 
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
), 
    color: Colors.white,
    onPressed: () {},
    child: Padding(
        padding: EdgeInsets.only(left:0,top:15,bottom:15),
        
        child: Row(children: [
          img,Container(width:width-120,child:
          Align(
            alignment: Alignment.center,
            child: Column(
              children: [
                Text(systemName, style: TextStyle(fontSize: 18)),
                
              ],
            ),
          ),)
        ])))
])));
}

PS:我在另一个小部件的 for 循环中调用了这个小部件 9 次,当我将循环次数减少到 5 或更低时,按钮也可以正常工作。

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    根据 Flutter SDK highlightElevation 是当按钮被启用并按下时按钮的 Material。

    请参考https://api.flutter.dev/flutter/material/RawMaterialButton/highlightElevation.html

    highlightElevation 属性: 启用并按下按钮时按钮材质的高度。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-05
      • 1970-01-01
      • 1970-01-01
      • 2019-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-25
      相关资源
      最近更新 更多