修改圈子列表图片加载内存溢出问题

This commit is contained in:
CYH 2023-08-29 11:33:21 +08:00
parent f955acb850
commit 3d8c3f9cc3

View File

@ -20,10 +20,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import '../../../util/SharedPreferencesHelper.dart'; import '../../../util/SharedPreferencesHelper.dart';
import '../../../util/eventBus.dart'; import '../../../util/eventBus.dart';
const listBgWidget = Image(
image: AssetImage('assets/images/circle/circle_bg.png'),
fit: BoxFit.fill,
);
class InfoListView extends StatefulWidget { class InfoListView extends StatefulWidget {
// Get.lazyPut(() => ListLogic()); // Get.lazyPut(() => ListLogic());
@ -88,7 +85,13 @@ class InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClien
} catch (_) {} } catch (_) {}
}); });
circleId = widget.bean.id.toString(); circleId = widget.bean.id.toString();
// if (Get.currentRoute == AppRoutes.Home || Get.currentRoute == AppRoutes.MyCircle) {
loadCallOutListData(); loadCallOutListData();
// }
callRefreshCicle = EventBusManager.on<CallRefreshCircle>().listen((event) { callRefreshCicle = EventBusManager.on<CallRefreshCircle>().listen((event) {
if(widget.bean.id.toString() == event.circleId){ if(widget.bean.id.toString() == event.circleId){
loadCallOutListData(); loadCallOutListData();
@ -195,23 +198,23 @@ class InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClien
void pushMsgPage(Lists bean, String cicleId) async { void pushMsgPage(Lists bean, String cicleId) async {
if (widget.bean.is_limit&&widget.bean.amount>0) { // if (widget.bean.is_limit&&widget.bean.amount>0) {
showJoinCiclePiker(cicleId,widget.bean.amount.toString(),widget.bean.oldAmount.toString(),2,(payResult){ // showJoinCiclePiker(cicleId,widget.bean.amount.toString(),widget.bean.oldAmount.toString(),2,(payResult){
widget.bean.is_limit = false; // widget.bean.is_limit = false;
if (Get.isRegistered<CircleLogic>()) { // if (Get.isRegistered<CircleLogic>()) {
var logic = Get.find<CircleLogic>(); // var logic = Get.find<CircleLogic>();
for (var element in logic.circle.lists) { // for (var element in logic.circle.lists) {
if (element.id == widget.bean.id) { // if (element.id == widget.bean.id) {
element.is_limit = false; // element.is_limit = false;
element.isJoin = true; // element.isJoin = true;
} // }
} // }
logic.update(); // logic.update();
} // }
Get.back(); // Get.back();
},widget.bean.ios_item); // },widget.bean.ios_item);
return; // return;
} // }
var sp = await SharedPreferencesHelper.getInstance(); var sp = await SharedPreferencesHelper.getInstance();
String myUserId = sp.getMyUserId(); String myUserId = sp.getMyUserId();
@ -225,6 +228,7 @@ class InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClien
url: "/up-service/callout/${bean.id}/chat",); url: "/up-service/callout/${bean.id}/chat",);
if (data["code"] == 200) { if (data["code"] == 200) {
pushChatPage(data['data']['account_id'].toString().split("_").last,data['data']['account_id'], bean.user!.nickname!); pushChatPage(data['data']['account_id'].toString().split("_").last,data['data']['account_id'], bean.user!.nickname!);
await Future.delayed(Duration(seconds: 1)); await Future.delayed(Duration(seconds: 1));
SharedPreferences sharedPreferences =await SharedPreferences.getInstance(); SharedPreferences sharedPreferences =await SharedPreferences.getInstance();
// SharedPreferencesHelper.getInstance().then((sharedPreferences) { // SharedPreferencesHelper.getInstance().then((sharedPreferences) {
@ -233,8 +237,6 @@ class InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClien
String name = sharedPreferences.getString(SharedPreferencesHelper.NAME)??""; String name = sharedPreferences.getString(SharedPreferencesHelper.NAME)??"";
bean.chat!.users!.add(Users(avatar: avatar,id: userId,nickname: name)); bean.chat!.users!.add(Users(avatar: avatar,id: userId,nickname: name));
widget.logic.update(); widget.logic.update();
// });
} }
} }
@ -251,7 +253,7 @@ class InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClien
} }
widgets.add(Positioned( widgets.add(Positioned(
left: 15.sp * i, left: 15.sp * i,
child: circleWidget(element.avatar??"https://qiniuyun.leyuan666.com/quanzi/avatar/default.png",element.id.toString()), child: circleWidget(element.avatar! ?? "https://qiniuyun.leyuan666.com/quanzi/avatar/default.png",element.id.toString()),
)); ));
i++; i++;
}); });
@ -270,7 +272,10 @@ class InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClien
borderRadius: BorderRadius.circular(10.sp), borderRadius: BorderRadius.circular(10.sp),
child: SizedBox( child: SizedBox(
width: Get.width, width: Get.width,
child: listBgWidget child: Image.asset(
getCircleImage('circle_bg'),
fit: BoxFit.fill,
),
)), )),
Container( Container(
height: Get.height, height: Get.height,
@ -289,6 +294,8 @@ class InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClien
// : // :
ListView.builder( ListView.builder(
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),
addAutomaticKeepAlives:false,
addRepaintBoundaries:false,
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
controller: scrollController, controller: scrollController,
itemCount: lists.length + 2, itemCount: lists.length + 2,
@ -411,10 +418,12 @@ class InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClien
padding: EdgeInsets.all(1.sp), padding: EdgeInsets.all(1.sp),
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.circular(8.0), borderRadius: BorderRadius.circular(8.0),
child: Image.network( child: CachedNetworkImage(
widget.bean.image, imageUrl:widget.bean.image,
width: 40.sp, width: 40.sp,
height: 40.sp, height: 40.sp,
memCacheHeight: 40,
memCacheWidth: 40,
fit:BoxFit.cover fit:BoxFit.cover
), ),
), ),
@ -707,8 +716,8 @@ class InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClien
width: 42.sp, width: 42.sp,
), ),
ClipOval( ClipOval(
child: Image.network( child: CachedNetworkImage(
lists.user!.avatar_thumb!, imageUrl:lists.user!.avatar_thumb!,
width: 40.sp, width: 40.sp,
height: 40.sp, height: 40.sp,
fit: BoxFit.cover, fit: BoxFit.cover,
@ -1013,11 +1022,13 @@ class InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClien
width: 42.sp, width: 42.sp,
), ),
ClipOval( ClipOval(
child: Image.network( child: CachedNetworkImage(
lists.user!.avatar!, imageUrl:lists.user!.avatar_thumb!,
width: 40.sp, width: 40.sp,
height: 40.sp, height: 40.sp,
fit: BoxFit.cover, fit: BoxFit.cover,
memCacheHeight: 40,
memCacheWidth: 40,
), ),
) )
], ],
@ -1191,6 +1202,7 @@ class InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClien
onTap: () async{ onTap: () async{
pushMsgPage(lists, widget.bean.id.toString()); pushMsgPage(lists, widget.bean.id.toString());
// });
}, },
child: Image.asset( child: Image.asset(
getCircleImage('chat'), getCircleImage('chat'),
@ -1219,11 +1231,13 @@ class InfoListViewState extends State<InfoListView> with AutomaticKeepAliveClien
width: width.sp, width: width.sp,
), ),
ClipOval( ClipOval(
child: Image.network( child: CachedNetworkImage(
url??"https://qiniuyun.leyuan666.com/quanzi/avatar/default.png", imageUrl:url??"https://qiniuyun.leyuan666.com/quanzi/avatar/default.png",
width: (width - 1).sp, width: (width - 1).sp,
height: (width - 1).sp, height: (width - 1).sp,
fit: BoxFit.cover, fit: BoxFit.cover,
memCacheHeight: width.toInt() - 1,
memCacheWidth: width.toInt() - 1,
), ),
) )
], ],