///处理banner data
_handlerBannerData(Response response) {
if (response.code == 0 || response.code == 200) {
List<BannerModel> list = [];
if (response.data is List) {
//data本来是个对象的,后台返回了个数组,那就判断是否是列表
(response.data as List).map((e) {
//如果是强转类型,然后循环获取里面的值
print('广告信息123-$e');
PrintUtil.prints('banner data=>$e');
list.add(BannerModel.fromJson(e));//添加在列表里面
}).toList();
}
if (list.isNotEmpty) {
_bannersListener.value = list;
if(list.length>1){
widget.controller.stopAutoplay();
widget.controller.startAutoplay();
}
}else {
print('广告信息123-为空');
}
}
}
Flutter determines whether the data is of list type, and then obtains the value inside
Guess you like
Origin blog.csdn.net/weixin_44911775/article/details/133762517
Ranking