From 5b511a63d645eb430a05a5495e8ca393affd5516 Mon Sep 17 00:00:00 2001 From: fmk Date: Tue, 26 Oct 2021 22:38:33 +0800 Subject: [PATCH] safety --- lib/community/community_child_page.dart | 11 ++- .../community_view/community_dynamic.dart | 98 +++++++++---------- 2 files changed, 54 insertions(+), 55 deletions(-) diff --git a/lib/community/community_child_page.dart b/lib/community/community_child_page.dart index 886387e7..7e66fda4 100644 --- a/lib/community/community_child_page.dart +++ b/lib/community/community_child_page.dart @@ -108,15 +108,18 @@ class _CommunityChildPage extends State { 0, userId: userId, isList: true, - exitFull: (){setState(() { - _onRefresh(); - });}, + exitFull: () { + setState(() { + _onRefresh(); + }); + }, ), onTap: () { Navigator.of(context).pushNamed( '/router/community_details', arguments: { - "comment": comments[position],"userId":userId, + "comment": comments[position], + "userId": userId, }, ); }, diff --git a/lib/community/community_view/community_dynamic.dart b/lib/community/community_view/community_dynamic.dart index 453f21b3..9e9d6374 100644 --- a/lib/community/community_view/community_dynamic.dart +++ b/lib/community/community_view/community_dynamic.dart @@ -1,6 +1,4 @@ -import 'dart:io'; import 'dart:ui'; - import 'package:chewie/chewie.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; @@ -16,7 +14,6 @@ import 'package:huixiang/view_widget/icon_text.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:image_pickers/image_pickers.dart'; -import 'package:path_provider/path_provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:video_player/video_player.dart'; @@ -40,7 +37,7 @@ class CommunityDynamic extends StatefulWidget { this.isDetails = false, this.removalDynamic, this.exitFull, - this.userId, + this.userId, this.isList = false, }) : super(key: key); @@ -59,7 +56,6 @@ class _CommunityDynamic extends State { ChewieController chewieAudioController; Chewie chewies; - @override void initState() { super.initState(); @@ -119,6 +115,7 @@ class _CommunityDynamic extends State { if (baseData != null && baseData.isSuccess) { widget.exitFull(); SmartDialog.showToast("关注成功", alignment: Alignment.center); + setState(() {}); } else { // SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } @@ -130,6 +127,7 @@ class _CommunityDynamic extends State { if (baseData != null && baseData.isSuccess) { widget.exitFull(); SmartDialog.showToast("删除成功", alignment: Alignment.center); + setState(() {}); } else { // SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } @@ -169,14 +167,14 @@ class _CommunityDynamic extends State { child: Row( children: [ MImage( - widget?.comment?.memberInfo?.avatar ?? "", - width: 44, - height: 44, - isCircle: true, - fit: BoxFit.cover, - errorSrc: "assets/image/default_1.png", - fadeSrc: "assets/image/default_1.png", - ), + widget?.comment?.memberInfo?.avatar ?? "", + width: 44, + height: 44, + isCircle: true, + fit: BoxFit.cover, + errorSrc: "assets/image/default_1.png", + fadeSrc: "assets/image/default_1.png", + ), SizedBox( width: 8, ), @@ -205,14 +203,14 @@ class _CommunityDynamic extends State { ], ), ), - if(widget?.comment?.memberInfo?.mid != widget.userId??"") + if (widget?.comment?.memberInfo?.mid != widget.userId ?? "") GestureDetector( onTap: () { setState(() { if (widget.commentType == 0) { widget.comment.selfFollow = - !(widget.comment.selfFollow ?? false); - _vipFollow(widget.comment.memberInfo.mid); + !(widget.comment.selfFollow ?? false); + _vipFollow(widget.comment.memberInfo?.mid); } else { showDeleteDialog(); } @@ -220,39 +218,39 @@ class _CommunityDynamic extends State { }, child: (widget.commentType == 0) ? Container( - width: 56.w, - height: 21.h, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(11.w), - color: Color(0xFF32A060), - ), - child: RoundButton( - backgroup: (widget.comment.selfFollow ?? false) - ? Color(0xFFE6E6E6) - : Color(0xFF32A060), - textColor: (widget.comment.selfFollow ?? false) - ? Color(0xFF808080) - : Colors.white, - text: (widget.comment.selfFollow ?? false) - ? "已关注" - : "关注", - radius: 20, - icons: Icon( - (widget.comment.selfFollow ?? false) - ? Icons.check - : Icons.add, - color: (widget.comment.selfFollow ?? false) - ? Color(0xFF808080) - : Colors.white, - size: 15, - ), - )) + width: 56.w, + height: 21.h, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(11.w), + color: Color(0xFF32A060), + ), + child: RoundButton( + backgroup: (widget.comment.selfFollow ?? false) + ? Color(0xFFE6E6E6) + : Color(0xFF32A060), + textColor: (widget.comment.selfFollow ?? false) + ? Color(0xFF808080) + : Colors.white, + text: (widget.comment.selfFollow ?? false) + ? "已关注" + : "关注", + radius: 20, + icons: Icon( + (widget.comment.selfFollow ?? false) + ? Icons.check + : Icons.add, + color: (widget.comment.selfFollow ?? false) + ? Color(0xFF808080) + : Colors.white, + size: 15, + ), + )) : Icon( - Icons.close, - color: Colors.black, - size: 16, - ), + Icons.close, + color: Colors.black, + size: 16, + ), ), ], ), @@ -294,9 +292,7 @@ class _CommunityDynamic extends State { iconSize: 16, ), GestureDetector( - onTap: (){ - - }, + onTap: () {}, child: IconText( "${widget.comment.likes ?? 0}", space: 4.w,