图片列表判断空

hmxc
小赖 4 years ago
parent 51571d8798
commit 3a6f5ebca2

@ -1,8 +1,10 @@
import 'package:akuCommunity/model/common/img_model.dart';
class ActivityPeopleModel {
int id;
String name;
String tel;
List<ImgUrl> imgUrl;
List<ImgModel> imgUrl;
ActivityPeopleModel({this.id, this.name, this.tel, this.imgUrl});
@ -13,7 +15,7 @@ class ActivityPeopleModel {
if (json['imgUrl'] != null) {
imgUrl = [];
json['imgUrl'].forEach((v) {
imgUrl.add(new ImgUrl.fromJson(v));
imgUrl.add(new ImgModel.fromJson(v));
});
}
}
@ -29,31 +31,3 @@ class ActivityPeopleModel {
return data;
}
}
class ImgUrl {
String url;
String size;
int longs;
int paragraph;
int sort;
ImgUrl({this.url, this.size, this.longs, this.paragraph, this.sort});
ImgUrl.fromJson(Map<String, dynamic> json) {
url = json['url'];
size = json['size'];
longs = json['longs'];
paragraph = json['paragraph'];
sort = json['sort'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['url'] = this.url;
data['size'] = this.size;
data['longs'] = this.longs;
data['paragraph'] = this.paragraph;
data['sort'] = this.sort;
return data;
}
}

@ -8,13 +8,6 @@ class CommunityTopicModel {
List<ImgModel> imgUrl;
int activityNum;
String get firstImg {
if (imgUrl.isEmpty)
return '';
else
return imgUrl.first.url;
}
CommunityTopicModel(
{this.id,
this.title,

@ -8,12 +8,6 @@ class MyEventItemModel {
List<ImgModel> imgUrl;
String createDate;
String get firstImg {
String img = '';
if (imgUrl.isNotEmpty) img = imgUrl.first.url;
return img;
}
DateTime get date => DateUtil.getDateTime(createDate);
MyEventItemModel({this.id, this.content, this.imgUrl, this.createDate});

@ -1,3 +1,5 @@
import 'package:akuCommunity/model/common/img_model.dart';
class QuestionnaireDetialModel {
int id;
String title;
@ -5,7 +7,7 @@ class QuestionnaireDetialModel {
String beginDate;
String endDate;
List<QuestionnaireTopicVoList> questionnaireTopicVoList;
List<VoResourcesImgList> voResourcesImgList;
List<ImgModel> voResourcesImgList;
QuestionnaireDetialModel(
{this.id,
@ -31,7 +33,7 @@ class QuestionnaireDetialModel {
if (json['voResourcesImgList'] != null) {
voResourcesImgList = [];
json['voResourcesImgList'].forEach((v) {
voResourcesImgList.add(new VoResourcesImgList.fromJson(v));
voResourcesImgList.add(new ImgModel.fromJson(v));
});
} else
voResourcesImgList = [];
@ -115,31 +117,3 @@ class QuestionnaireChoiceVoList {
}
}
class VoResourcesImgList {
String url;
String size;
int longs;
int paragraph;
int sort;
VoResourcesImgList(
{this.url, this.size, this.longs, this.paragraph, this.sort});
VoResourcesImgList.fromJson(Map<String, dynamic> json) {
url = json['url'];
size = json['size'];
longs = json['longs'];
paragraph = json['paragraph'];
sort = json['sort'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['url'] = this.url;
data['size'] = this.size;
data['longs'] = this.longs;
data['paragraph'] = this.paragraph;
data['sort'] = this.sort;
return data;
}
}

@ -9,12 +9,6 @@ class VotingDetailModel {
List<ImgModel> imgUrls;
List<AppVoteCandidateVos> appVoteCandidateVos;
String get firstImage {
if (imgUrls == null) return '';
if (imgUrls.isEmpty) return '';
return imgUrls.first.url ?? '';
}
VotingDetailModel(
{this.id,
this.title,

@ -14,10 +14,6 @@ class CommitteeItemModel {
int estateNo;
List<ImgModel> imgUrls;
String get firstImg {
if (imgUrls.isEmpty) return '';
return imgUrls.first.url;
}
String get sexValue {
if (sexId == 0 || sexId == null) return '未设置';

@ -1,3 +1,4 @@
import 'package:akuCommunity/model/common/img_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
@ -60,8 +61,7 @@ class _EventVotingPageState extends State<EventVotingPage> {
child: ClipRect(
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(
model.imgUrls.isNotEmpty ? model.imgUrls.first.url : ''),
image: API.image(ImgModel.first(model.imgUrls)),
fit: BoxFit.cover,
),
),

@ -233,7 +233,7 @@ class _VotingDetailPageState extends State<VotingDetailPage> {
borderRadius: BorderRadius.circular(8.w),
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(_model.firstImage),
image: API.image(ImgModel.first(_model.imgUrls)),
),
),
44.w.heightBox,

@ -1,3 +1,4 @@
import 'package:akuCommunity/model/common/img_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -22,7 +23,7 @@ class GoodsManagePage extends StatefulWidget {
}
class _GoodsManagePageState extends State<GoodsManagePage> {
EasyRefreshController _easyRefreshController;
EasyRefreshController _easyRefreshController = EasyRefreshController();
Container _goodsCard(ArticleBorrowModel model) {
return Container(
@ -52,8 +53,9 @@ class _GoodsManagePageState extends State<GoodsManagePage> {
child: ClipRRect(
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(
model.imgUrls.isEmpty ? '' : model.imgUrls.first.url))),
image: API.image(ImgModel.first(model.imgUrls)),
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,

@ -1,3 +1,4 @@
import 'package:akuCommunity/model/common/img_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -80,7 +81,7 @@ class _IndustryCommitteePageState extends State<IndustryCommitteePage> {
borderRadius: BorderRadius.circular(4.w),
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(model.firstImg),
image: API.image(ImgModel.first(model.imgUrls)),
height: 150.w,
width: 150.w,
fit: BoxFit.cover,

@ -38,7 +38,7 @@ class CancelModel {
class _FixedDetailPageState extends State<FixedDetailPage> {
bool _onLoading = true;
EasyRefreshController _easyRefreshController;
EasyRefreshController _easyRefreshController = EasyRefreshController();
FixedDetailModel _model = FixedDetailModel();
bool get showRepairCard => _model?.appDispatchListVo != null;
bool get showProcessCard => _model.appProcessRecordVo.isNotEmpty;

@ -1,3 +1,4 @@
import 'package:akuCommunity/model/common/img_model.dart';
import 'package:flutter/material.dart';
import 'package:flustars/flustars.dart';
@ -18,8 +19,6 @@ class ActivityCard extends StatelessWidget {
@required this.model,
}) : super(key: key);
String get firstPath =>
(model.imgUrls?.isEmpty ?? true) ? null : model.imgUrls.first.url;
bool get outdate => model.end.compareTo(DateTime.now()) == -1;
Widget build(BuildContext context) {
return MaterialButton(
@ -38,15 +37,15 @@ class ActivityCard extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
firstPath == null
ImgModel.first(model.imgUrls) == null
? SizedBox()
: Hero(
tag: firstPath,
tag: ImgModel.first(model.imgUrls),
child: Material(
color: Colors.grey,
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(firstPath),
image: API.image(ImgModel.first(model.imgUrls)),
height: 210.w,
width: double.infinity,
fit: BoxFit.cover,

@ -1,3 +1,4 @@
import 'package:akuCommunity/model/common/img_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
@ -47,7 +48,7 @@ class _ActivityPeopleListPageState extends State<ActivityPeopleListPage> {
20.wb,
FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(model.imgUrl.first.url),
image: API.image(ImgModel.first(model.imgUrl)),
height: 60.w,
width: 60.w,
),

@ -1,5 +1,6 @@
import 'dart:ui';
import 'package:akuCommunity/model/common/img_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
@ -47,7 +48,7 @@ class TopicCommunityViewState extends State<TopicCommunityView>
children: [
FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(model.firstImg),
image: API.image(ImgModel.first(model.imgUrl)),
height: 160.w,
width: 250.w,
fit: BoxFit.cover,

@ -1,3 +1,4 @@
import 'package:akuCommunity/model/common/img_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@ -63,7 +64,7 @@ class _TopicDetailPageState extends State<TopicDetailPage> {
delegate: TopicSliverHeader(
id: widget.model.id,
title: widget.model.summary,
imgPath: widget.model.firstImg,
imgPath: ImgModel.first(widget.model.imgUrl),
subTitle: widget.model.content,
),
pinned: true,

@ -47,14 +47,6 @@ class _ChatCardState extends State<ChatCard> {
return (userProvider?.userInfoModel?.id ?? -1) == widget.model.createId;
}
String get firstHead {
if (widget.model.headSculptureImgUrl == null ||
widget.model.headSculptureImgUrl.isEmpty)
return '';
else
return widget.model.headSculptureImgUrl.first.url;
}
_renderImage() {
if (widget.model.imgUrls.isEmpty) return SizedBox();
if (widget.model.imgUrls.length == 1)
@ -78,10 +70,10 @@ class _ChatCardState extends State<ChatCard> {
maxWidth: 300.w,
),
child: Hero(
tag: widget.model.imgUrls.first.url,
tag: ImgModel.first(widget.model.imgUrls),
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(widget.model.imgUrls.first.url),
image: API.image(ImgModel.first(widget.model.imgUrls)),
),
),
),
@ -306,7 +298,8 @@ class _ChatCardState extends State<ChatCard> {
clipBehavior: Clip.antiAlias,
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(firstHead),
image:
API.image(ImgModel.first(widget.model.headSculptureImgUrl)),
height: 86.w,
width: 86.w,
fit: BoxFit.cover,

@ -1,3 +1,4 @@
import 'package:akuCommunity/model/common/img_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -219,11 +220,13 @@ class _QuestionnaireDetailPageState extends State<QuestionnaireDetailPage> {
borderRadius: BorderRadius.circular(4.w),
),
width: double.infinity,
height: 228.w,
clipBehavior: Clip.antiAlias,
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_LOGO_PNG,
image: API.image(_model.voResourcesImgList.first.url)),
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(
ImgModel.first(_model.voResourcesImgList),
),
),
),
40.w.heightBox,
Container(

@ -1,3 +1,4 @@
import 'package:akuCommunity/model/common/img_model.dart';
import 'package:flutter/material.dart';
import 'package:flustars/flustars.dart';
@ -21,7 +22,7 @@ class QuestionnairePage extends StatefulWidget {
}
class _QuestionnairePageState extends State<QuestionnairePage> {
EasyRefreshController _easyRefreshController;
EasyRefreshController _easyRefreshController = EasyRefreshController();
@override
void initState() {
super.initState();
@ -68,8 +69,9 @@ class _QuestionnairePageState extends State<QuestionnairePage> {
height: 120.w,
child: ClipRRect(
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_LOGO_PNG,
image: API.image(model.imgUrls.first.url)),
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(ImgModel.first(model.imgUrls)),
),
),
),
20.w.widthBox,
@ -146,6 +148,12 @@ class _QuestionnairePageState extends State<QuestionnairePage> {
);
}
@override
void dispose() {
_easyRefreshController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return BeeScaffold(

Loading…
Cancel
Save