【问题标题】:Raw material button not responding to clicks flutter原材料按钮不响应点击颤动
【发布时间】:2018-06-09 12:53:13
【问题描述】:

我应该将材质作为 Raw material 按钮的父级放置在哪里,以便它可以响应点击并显示启动颜色。 小部件树如下所示。

     Widget build(BuildContext context) {
     return new Container(
     child: new Center(
     child: new Stack(
      alignment: Alignment.center,
      children: <Widget>[
        new Container(
          child: new Padding(
            padding: const EdgeInsets.all(5.0),
            child: new Container(
              child: new AudioComponent(
                updateMe: [WatchableAudioProperties.audioPlayerState],
                    playerBuilder: (BuildContext context, AudioPlayer 
                     player,
                    Widget child) {
                    IconData icon = Icons.play_arrow;

                  return new RawMaterialButton(
                    shape: new CircleBorder(),
                    fillColor: Colors.white,
                    splashColor: lightAccentColor,
                    highlightColor: lightAccentColor.withOpacity(0.5),
                    elevation: 10.0,
                    highlightElevation: 5.0,
                    onPressed: (){},
                    child: new Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: new Icon(
                        icon,
                        color: accentColor,
                        size: 50.0,
                      ),
                    ),
                  );
                },
              ),
            ),
          ),
        ),
        new Container(
          height: 151.0,
          width: 151.0,
          child: waves,
        ),
      ],
    ),
  ),
  );
 }

如果我将另一个容器添加到堆栈中并放置一个类似的 RawMaterial 按钮,即使没有在任何地方添加材质小部件,它也会根据需要做出响应。我不明白为什么堆栈中第一个容器中的 RawButton 不起作用

【问题讨论】:

  • 也许你的Container 覆盖了按钮,所以它没有触摸输入

标签: flutter flutter-layout


【解决方案1】:

当您的定义中有以下代码时,您希望您的RawMaterialButton 有什么反应?

onPressed: (){},

【讨论】:

  • 任何按钮都会将其作为代码做出反应。它应该赋予它按钮的功能而无需执行功能
猜你喜欢
  • 2021-08-11
  • 1970-01-01
  • 2020-12-13
  • 1970-01-01
  • 1970-01-01
  • 2021-09-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多