今天就跟大家聊聊有關如何使用flutter動態(tài)加載網(wǎng)絡圖片,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

成都創(chuàng)新互聯(lián)公司提供做網(wǎng)站、成都網(wǎng)站設計、網(wǎng)頁設計,高端網(wǎng)站設計,一元廣告等致力于企業(yè)網(wǎng)站建設與公司網(wǎng)站制作,10年的網(wǎng)站開發(fā)和建站經(jīng)驗,助力企業(yè)信息化建設,成功案例突破成百上千,是您實現(xiàn)網(wǎng)站建設的好選擇.
需要添加依賴包
flukit: ^1.0.0 引用 import 'package:flukit/flukit.dart'; //這一坨放在自己想要顯示輪播圖的地方 AspectRatio( aspectRatio:1.0,// 16.0 / 9.0, child: Swiper( indicatorAlignment: AlignmentDirectional.topEnd, circular: true, autoStart:false, indicator: NumberSwiperIndicator(),//使用的官方的 分數(shù)下標 children:AspecRaticImgs(pro.image),//這里是一個List<String>類型的參數(shù),存放的圖片Url列表 ), );
//輪播圖片
class NumberSwiperIndicator extends SwiperIndicator{
@override
Widget build(BuildContext context, int index, int itemCount) {
if(itemCount>1){
return Container(
decoration: BoxDecoration(
color: Colors.black45,
borderRadius: BorderRadius.circular(20.0)
),
margin: EdgeInsets.only(top: 10.0,right: 5.0),
padding: EdgeInsets.symmetric(horizontal: 6.0,vertical: 2.0),
child: Text("${++index}/$itemCount", style: TextStyle(color: SQColor.white, fontSize: 18.0)),
);
}else{
return Container();
}
}
}
//這里我一開始用foreach循環(huán),發(fā)現(xiàn)不行 會報錯,說我add時用了空對象,頭疼,與C#真的是大相徑庭
List<Widget> AspecRaticImgs(List<String> imgUrl) {
return imgUrl.map<Widget>((url){
return Image.network(
url,
height: 400,
fit: BoxFit.cover,
);
}).toList();
}
List<Widget> AspecRaticImgs(List<String> imgUrl) {
return imgUrl.map<Widget>((url){
return CachedNetworkImage(//這個加載更加舒服,當在加載中的時候,有一個加載進度
imageUrl: url,
height: 400,
fit: BoxFit.cover,
placeholder: CustomWidgets.loadingPlaceHolder,
errorWidget: Image.asset('images/bg_gray.png',height: 400),
);
}).toList();
}看完上述內(nèi)容,你們對如何使用flutter動態(tài)加載網(wǎng)絡圖片有進一步的了解嗎?如果還想了解更多知識或者相關內(nèi)容,請關注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。
當前名稱:如何使用flutter動態(tài)加載網(wǎng)絡圖片
鏈接地址:http://chinadenli.net/article34/jpchse.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站營銷、電子商務、外貿(mào)網(wǎng)站建設、Google、網(wǎng)站維護、搜索引擎優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)