///处理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 判断data是否是list类型,然后获取里面的值
猜你喜欢
转载自blog.csdn.net/weixin_44911775/article/details/133762517
今日推荐
周排行