【问题标题】:How can I remove press animation of RaisedButton in Flutter?如何在 Flutter 中删除 RaisedButton 的按下动画?
【发布时间】:2020-08-22 13:15:37
【问题描述】:

您好,我想删除在 Flutter 中按下“RaisedButton”时出现的动画。

我该怎么做?

RaisedButton(
                splashColor: Colors.transparent,
                highlightColor: Colors.transparent,
                padding: EdgeInsets.all(0),
                color: Colors.white,
                elevation: 0,
                onPressed: (){
                  Navigator.push(
                      context,  // 기본 파라미터, SecondRoute로 전달
                      MaterialPageRoute(builder: (context)=>TotalNotification()) // SecondRoute를 생성하여 적재
                  );
                },
                child: SvgPicture.asset(
                  'assets/images/BellButton.svg',
                  width: screenWidth * 0.0777777777777778,
                  height: screenWidth * 0.0777777777777778,
                ),
              ),

【问题讨论】:

  • 您是否尝试过使用 IconButton 而不是 RaisedButton?
  • 我使用手势检测器解决了这个问题,但我也会试试这个 :)

标签: flutter


【解决方案1】:

我可以给你一个想法。
只需用Container 而不是RaisedButton 包装它,并寻求GesureDetector 的帮助

GestureDetector(
          onTap: () {
            Navigator.push( context,  MaterialPageRoute(builder: (context)=>TotalNotification()));
          },
          child: Container(
            height: 50.0,
            width: 50.0,
            color: Colors.white,
            child: SvgPicture.asset(
                  'assets/images/BellButton.svg',
                  width: screenWidth * 0.0777777777777778,
                  height: screenWidth * 0.0777777777777778,
            ),
       ),
   ),

希望这适合你的情况!

【讨论】:

  • 非常感谢!!!!!!它对我来说很完美!!祝你有美好的一天!
猜你喜欢
  • 2019-04-30
  • 2021-11-06
  • 1970-01-01
  • 2019-01-25
  • 2020-05-14
  • 1970-01-01
  • 2020-07-19
  • 2021-09-28
  • 1970-01-01
相关资源
最近更新 更多