不知到大家在軟件開發(fā)過程中,首頁一般展示UI都會有1個橫向的互動列表這里面會根據(jù)你的瀏覽記錄進行埋點,去推薦你喜歡的商品。
那么話不多說,我們開始來詳細描述網(wǎng)絡(luò)數(shù)據(jù)和猜你喜歡列表組件綁定實現(xiàn)過程:
1 獲取猜你喜歡數(shù)據(jù)的url
https://www.itying.com/api/plist?is_hot=1
2 打開jsonToDart的網(wǎng)頁,把json拷貝到里面點擊Gennerate Dart自動生成數(shù)據(jù)模型
jsonToDart的網(wǎng)頁:https://javiercbk.github.io/json_to_dart/

jsonToDart的網(wǎng)頁
3 在Model文件下創(chuàng)建ProductModel.dart文件,然后把自動上一步自動生成的模型copy到文件里面,并重新命名ProductModel+ProductItemModel

ProductModel
4 封裝_getHotProductData方法調(diào)用dio獲取猜你喜歡數(shù)據(jù)的網(wǎng)絡(luò)數(shù)據(jù)

聲明猜你喜歡列表數(shù)組

_getHotProductData
5 回到猜你喜歡UI組件函數(shù)_hotProductListNetWidget,將猜你喜歡數(shù)組和UI進行數(shù)據(jù)綁定

_hotProductListNetWidget
6 執(zhí)行flutter run命令 測試UI看效果
