簡體   English   中英

Flutter:如何從 API 獲取數據並以列表形式顯示 flutter 中的圖像?

[英]Flutter : How to fetch data from API and show in the list form with image in flutter?

下面給出了如何從 api.API 響應中獲取數據。 以列表形式顯示 flutter 中的圖像。

{
    "status": 1,
    "msg": "7 banners found",
    "data": [
        {
            "id": "14",
            "image": "https://www.sofikart.com/admin/upload/app_banner/1635945056.jpeg",
            "cat_id": "4",
            "product_id": "81",
            "url": null,
            "status": "Active",
            "ordering": "0",
            "updated": "2021-11-03 06:10:56"
        },
        {
            "id": "7",
            "image": "https://www.sofikart.com/admin/upload/app_banner/1642082634.jpeg",
            "cat_id": "4",
            "product_id": "111",
            "url": null,
            "status": "Active",
            "ordering": "1",
            "updated": "2021-10-28 04:53:26"
        }
    ] }

在這種情況下,Flutter 有一個很好的文檔和示例,我很確定這會對你有所幫助。

你可以看這里

大多數應用程序都需要從 Internet 獲取數據。 幸運的是,Dart 和 Flutter 提供了工具,例如 http ZEFE90A8E604A7C847D8ZF0 的 ZEFE90A8E604A7C847ED8ZF0 等工具。

此配方使用以下步驟:

  1. 添加 http package。
  2. 使用 http package 發出網絡請求。
  3. 將響應轉換為自定義 Dart object。
  4. 使用 Flutter 獲取並顯示數據。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM