简体   繁体   English

Flutter:如何从 API 获取数据并以列表形式显示 flutter 中的图像?

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

How to fetch data from api.API responses is given below.下面给出了如何从 api.API 响应中获取数据。 show in the list form with image in flutter.以列表形式显示 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"
        }
    ] }

In this case, Flutter has a nice documentation with examples, that I'm pretty sure that will help you.在这种情况下,Flutter 有一个很好的文档和示例,我很确定这会对你有所帮助。

You can look here你可以看这里

Fetching data from the internet is necessary for most apps.大多数应用程序都需要从 Internet 获取数据。 Luckily, Dart and Flutter provide tools, such as the http package, for this type of work.幸运的是,Dart 和 Flutter 提供了工具,例如 http ZEFE90A8E604A7C847D8ZF0 的 ZEFE90A8E604A7C847ED8ZF0 等工具。

This recipe uses the following steps:此配方使用以下步骤:

  1. Add the http package.添加 http package。
  2. Make a network request using the http package.使用 http package 发出网络请求。
  3. Convert the response into a custom Dart object.将响应转换为自定义 Dart object。
  4. Fetch and display the data with Flutter.使用 Flutter 获取并显示数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM