【问题标题】:How to show onclick button animation layout in Flutter?如何在 Flutter 中显示 onclick 按钮动画布局?
【发布时间】:2019-09-10 20:01:53
【问题描述】:

我想在按下按钮时在屏幕上显示透明布局。

我尝试使用 Stack 并且它工作正常,但是当我按下函数内部的按钮时(例如 ExercisePage()),覆盖不显示。

当值为overlayShouldBeVisible==true 时,叠加层起作用。 但是从ExercisePage(),按钮按下事件内部更改overlayShouldBeVisible 的值,不会出现覆盖。

Stack(
      fit: StackFit.passthrough,
      children: <Widget>[

        ExercisePage(),

       overlayShouldBeVisible==true?new CorrectWrongOverlay(isCorrect) : new Container() ,
      ],
    ); 

【问题讨论】:

    标签: dart flutter flutter-layout flutter-animation flutter-test


    【解决方案1】:

    我不知道你在ExercisePage() 中做了什么,但我可以给你一些建议。尝试使用值通知器来更改变量https://api.flutter.dev/flutter/foundation/ValueNotifier-class.html的值

    根据 overlayShouldBeVisible 值,您可以使用 if 条件来显示 CorrectWrongOverlay 与否,而无需在树中放置另一个小部件。

    【讨论】:

      猜你喜欢
      • 2017-05-06
      • 2018-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-10
      • 1970-01-01
      • 1970-01-01
      • 2014-10-09
      相关资源
      最近更新 更多