【问题标题】:How To show Pop animation on deletion of message in chat?如何在聊天中删除消息时显示弹出动画?
【发布时间】:2020-11-14 19:21:05
【问题描述】:

我使用 Firebase 制作了一个 Flutter 聊天应用。

我正在使用流构建器收听消息。我的聊天应用的另一个特点是,当用户长按他的聊天消息时,该消息会被删除。

我想显示已删除消息的弹出动画,因为现在消息被突然删除。

【问题讨论】:

    标签: flutter flutter-animation


    【解决方案1】:

    您可以为此使用显示对话框。

    
    void _showDialog() {
        // flutter defined function
        showDialog(
          context: context,
          builder: (BuildContext context) {
            // return object of type Dialog
            return AlertDialog(
              content: new Text("Are you sure you want to delete?"),
              actions: <Widget>[
                // usually buttons at the bottom of the dialog
                FlatButton(
                  child: new Text("Delete"),
                  onPressed: () {
                    // Your deleteMessage method!
                  },
                ),
                FlatButton(
                  child: new Text("Close"),
                  onPressed: () {
                    Navigator.of(context).pop();
                  },
                ),
              ],
            );
          },
        );
      }
    
    

    您可以从official document 了解更多信息。

    【讨论】:

    • 我的问题不是如何要求用户删除消息,而是如何显示该已删除消息的某种类型的 Pop 或破坏动画,而不是突然删除。因为使用对话框或直接删除是一回事。问题更侧重于删除动画。
    【解决方案2】:

    您需要的是动画小部件,我不知道您需要什么样的动画或如何使用它,但制作它的最佳方法是观看或阅读来自flutter official doc 的动画小部件

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-25
      • 1970-01-01
      • 2017-06-01
      • 2012-05-28
      相关资源
      最近更新 更多