Flutter高仿微信系列共59篇,从Flutter客户端、Kotlin客户端、Web服务器、数据库表结构、Xmpp即时通讯服务器、视频通话服务器、腾讯云服务器全面讲解。

 详情请查看

效果图:

实现代码:

//删除对话框
Future<void> _showDeleteDialog(ChatBean chatBean) async {
  return showDialog<Null>(
      context: context,
      barrierDismissible: false,
      builder: (BuildContext context) {
        return AlertDialog(
          title: Text('确定要删除该消息吗?', style: new TextStyle(fontSize: 17.0)),
          actions: <Widget>[
            MaterialButton(
              child: Text('取消'),
              onPressed: (){
                Navigator.of(context).pop();
              },
            ),
            MaterialButton(
              child: Text('确定'),
              onPressed: (){
                Navigator.pop(context);
                _deleteChatBean(chatBean);
              },
            )
          ],
        );
      }
  );
}
//删除本地记录后返回刷新页面
_deleteChatBean(ChatBean chatBean) async{
  int id = chatBean.id??0;
  await ChatRepository.getInstance().deleteChatById(id);
  widget.deleteCallback(true);
}

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐