Json flatter http.get无法获取身体数据

Json flatter http.get无法获取身体数据,json,flutter,dart,flutter-http,Json,Flutter,Dart,Flutter Http,我试图从我的json提要中获取数据,这就是 但是,当我尝试使用body结果时,它不起作用(但它可以与其他JSON一起工作,如下图所示),我的代码如下所示: import 'package:flutter/cupertino.dart'; import 'package:http/http.dart' as http; import 'noticias.dart'; class Services { static const String url = 'https://studiofutbo

我试图从我的json提要中获取数据,这就是

但是,当我尝试使用body结果时,它不起作用(但它可以与其他JSON一起工作,如下图所示),我的代码如下所示:

import 'package:flutter/cupertino.dart';
import 'package:http/http.dart' as http;
import 'noticias.dart';

class Services {
static const String url =
  'https://studiofutbol.com.ec/api/json/feed_master.php?pagina=';

static Future<Portada> getNoticias() async {
try {
  var headers = {
    'Content-Type': 'application/x-www-form-urlencoded',
    'X-Requested-With': 'XMLHttpRequest',
  };
  final response = await http.get(url, headers: headers);
  debugPrint(response.body);
  if (200 == response.statusCode) {
    final Portada noticiasportada = portadaFromJson(response.body);
    return noticiasportada;
  } else {
    return Portada();
  }
} catch (e) {
  return Portada();
}
  }
}
import'包装:flift/cupertino.dart';
将“package:http/http.dart”导入为http;
输入‘noticias.dart’;
班级服务{
静态常量字符串url=
'https://studiofutbol.com.ec/api/json/feed_master.php?pagina=';
静态未来getNotifias()异步{
试一试{
变量头={
“内容类型”:“应用程序/x-www-form-urlencoded”,
“X-request-With':“XMLHttpRequest”,
};
final response=wait http.get(url,headers:headers);
debugPrint(response.body);
if(200==响应.状态码){
最终portadanotifiasportada=portadaFromJson(response.body);
退货通知单;
}否则{
返回Portada();
}
}捕获(e){
返回Portada();
}
}
}

我添加了这些标题,但没有任何帮助,是什么导致了问题?

对我来说是这样的

Future<Portada> getNoticias() async {
    try {
      HttpClient httpClient = new HttpClient();
      HttpClientRequest request = await httpClient.getUrl(Uri.parse(
          "https://studiofutbol.com.ec/api/json/feed_master.php?pagina="));
      request.headers.set('content-type', 'application/json');
     
      HttpClientResponse response = await request.close();
      String reply = await response.transform(utf8.decoder).join();
      print(reply);
      httpClient.close();
      Map<String, dynamic> map = json.decode(reply);
      final Portada noticiasportada = Portada.fromMap(map);
      return noticiasportada;
    } catch (e) {
      return Portada();
    }
  }
Future GetNotifias()异步{
试一试{
HttpClient HttpClient=新HttpClient();
HttpClientRequest请求=等待httpClient.getUrl(Uri.parse(
"https://studiofutbol.com.ec/api/json/feed_master.php?pagina="));
request.headers.set('content-type','application/json');
HttpClientResponse response=等待请求。关闭();
String reply=wait response.transform(utf8.decoder.join();
打印(答复);
httpClient.close();
Map Map=json.decode(回复);
最终Portada noticeisportada=Portada.fromMap(map);
退货通知单;
}捕获(e){
返回Portada();
}
}
模范班

import 'dart:convert';

Portada portadaFromMap(String str) => Portada.fromMap(json.decode(str));

String portadaToMap(Portada data) => json.encode(data.toMap());

class Portada {
  Portada({
    this.json,
    this.menu,
    this.banners,
    this.tags,
    this.equipos,
    this.menuIos,
    this.version,
    this.versionIos,
  });

  List<Json> json;
  List<Menu> menu;
  Banners banners;
  List<Tag> tags;
  List<Equipo> equipos;
  List<MenuIo> menuIos;
  String version;
  String versionIos;

  factory Portada.fromMap(Map<String, dynamic> json) => Portada(
    json: json["Json"] == null ? null : List<Json>.from(json["Json"].map((x) => Json.fromMap(x))),
    menu: json["menu"] == null ? null : List<Menu>.from(json["menu"].map((x) => Menu.fromMap(x))),
    banners: json["banners"] == null ? null : Banners.fromMap(json["banners"]),
    tags: json["tags"] == null ? null : List<Tag>.from(json["tags"].map((x) => Tag.fromMap(x))),
    equipos: json["equipos"] == null ? null : List<Equipo>.from(json["equipos"].map((x) => Equipo.fromMap(x))),
    menuIos: json["menu_ios"] == null ? null : List<MenuIo>.from(json["menu_ios"].map((x) => MenuIo.fromMap(x))),
    version: json["version"] == null ? null : json["version"],
    versionIos: json["version_ios"] == null ? null : json["version_ios"],
  );

  Map<String, dynamic> toMap() => {
    "Json": json == null ? null : List<dynamic>.from(json.map((x) => x.toMap())),
    "menu": menu == null ? null : List<dynamic>.from(menu.map((x) => x.toMap())),
    "banners": banners == null ? null : banners.toMap(),
    "tags": tags == null ? null : List<dynamic>.from(tags.map((x) => x.toMap())),
    "equipos": equipos == null ? null : List<dynamic>.from(equipos.map((x) => x.toMap())),
    "menu_ios": menuIos == null ? null : List<dynamic>.from(menuIos.map((x) => x.toMap())),
    "version": version == null ? null : version,
    "version_ios": versionIos == null ? null : versionIos,
  };
}

class Banners {
  Banners({
    this.splash,
    this.splashiphone,
    this.main,
    this.interna,
  });

  Interna splash;
  Interna splashiphone;
  Interna main;
  Interna interna;

  factory Banners.fromMap(Map<String, dynamic> json) => Banners(
    splash: json["splash"] == null ? null : Interna.fromMap(json["splash"]),
    splashiphone: json["splashiphone"] == null ? null : Interna.fromMap(json["splashiphone"]),
    main: json["main"] == null ? null : Interna.fromMap(json["main"]),
    interna: json["interna"] == null ? null : Interna.fromMap(json["interna"]),
  );

  Map<String, dynamic> toMap() => {
    "splash": splash == null ? null : splash.toMap(),
    "splashiphone": splashiphone == null ? null : splashiphone.toMap(),
    "main": main == null ? null : main.toMap(),
    "interna": interna == null ? null : interna.toMap(),
  };
}

class Interna {
  Interna({
    this.imagen,
    this.link,
  });

  String imagen;
  String link;

  factory Interna.fromMap(Map<String, dynamic> json) => Interna(
    imagen: json["imagen"] == null ? null : json["imagen"],
    link: json["link"] == null ? null : json["link"],
  );

  Map<String, dynamic> toMap() => {
    "imagen": imagen == null ? null : imagen,
    "link": link == null ? null : link,
  };
}

class Equipo {
  Equipo({
    this.id,
    this.nombre,
  });

  int id;
  String nombre;

  factory Equipo.fromMap(Map<String, dynamic> json) => Equipo(
    id: json["id"] == null ? null : json["id"],
    nombre: json["nombre"] == null ? null : json["nombre"],
  );

  Map<String, dynamic> toMap() => {
    "id": id == null ? null : id,
    "nombre": nombre == null ? null : nombre,
  };
}

class Json {
  Json({
    this.id,
    this.title,
    this.titleint,
    this.permalink,
    this.content,
    this.excerpt,
    this.date,
    this.author,
    this.image,
    this.fuente,
    this.thumbnail,
    this.categories,
    this.tags,
    this.contentIphone,
    this.videoEnlace,
  });

  int id;
  String title;
  String titleint;
  String permalink;
  String content;
  String excerpt;
  DateTime date;
  String author;
  List<dynamic> image;
  String fuente;
  String thumbnail;
  List<String> categories;
  List<String> tags;
  String contentIphone;
  String videoEnlace;

  factory Json.fromMap(Map<String, dynamic> json) => Json(
    id: json["id"] == null ? null : json["id"],
    title: json["title"] == null ? null : json["title"],
    titleint: json["titleint"] == null ? null : json["titleint"],
    permalink: json["permalink"] == null ? null : json["permalink"],
    content: json["content"] == null ? null : json["content"],
    excerpt: json["excerpt"] == null ? null : json["excerpt"],
    date: json["date"] == null ? null : DateTime.parse(json["date"]),
    author: json["author"] == null ? null : json["author"],
    image: json["image"] == null ? null : List<dynamic>.from(json["image"].map((x) => x)),
    fuente: json["fuente"] == null ? null : json["fuente"],
    thumbnail: json["thumbnail"] == null ? null : json["thumbnail"],
    categories: json["categories"] == null ? null : List<String>.from(json["categories"].map((x) => x)),
    tags: json["tags"] == null ? null : List<String>.from(json["tags"].map((x) => x)),
    contentIphone: json["contentIphone"] == null ? null : json["contentIphone"],
    videoEnlace: json["video_enlace"] == null ? null : json["video_enlace"],
  );

  Map<String, dynamic> toMap() => {
    "id": id == null ? null : id,
    "title": title == null ? null : title,
    "titleint": titleint == null ? null : titleint,
    "permalink": permalink == null ? null : permalink,
    "content": content == null ? null : content,
    "excerpt": excerpt == null ? null : excerpt,
    "date": date == null ? null : date.toIso8601String(),
    "author": author == null ? null : author,
    "image": image == null ? null : List<dynamic>.from(image.map((x) => x)),
    "fuente": fuente == null ? null : fuente,
    "thumbnail": thumbnail == null ? null : thumbnail,
    "categories": categories == null ? null : List<dynamic>.from(categories.map((x) => x)),
    "tags": tags == null ? null : List<dynamic>.from(tags.map((x) => x)),
    "contentIphone": contentIphone == null ? null : contentIphone,
    "video_enlace": videoEnlace == null ? null : videoEnlace,
  };
}

class Menu {
  Menu({
    this.url,
    this.nombre,
  });

  String url;
  String nombre;

  factory Menu.fromMap(Map<String, dynamic> json) => Menu(
    url: json["url"] == null ? null : json["url"],
    nombre: json["nombre"] == null ? null : json["nombre"],
  );

  Map<String, dynamic> toMap() => {
    "url": url == null ? null : url,
    "nombre": nombre == null ? null : nombre,
  };
}

class MenuIo {
  MenuIo({
    this.nombre,
    this.url,
    this.segue,
    this.img,
  });

  String nombre;
  String url;
  String segue;
  String img;

  factory MenuIo.fromMap(Map<String, dynamic> json) => MenuIo(
    nombre: json["nombre"] == null ? null : json["nombre"],
    url: json["url"] == null ? null : json["url"],
    segue: json["segue"] == null ? null : json["segue"],
    img: json["img"] == null ? null : json["img"],
  );

  Map<String, dynamic> toMap() => {
    "nombre": nombre == null ? null : nombre,
    "url": url == null ? null : url,
    "segue": segue == null ? null : segue,
    "img": img == null ? null : img,
  };
}

class Tag {
  Tag({
    this.id,
    this.nombre,
    this.url,
  });

  int id;
  String nombre;
  String url;

  factory Tag.fromMap(Map<String, dynamic> json) => Tag(
    id: json["id"] == null ? null : json["id"],
    nombre: json["nombre"] == null ? null : json["nombre"],
    url: json["url"] == null ? null : json["url"],
  );

  Map<String, dynamic> toMap() => {
    "id": id == null ? null : id,
    "nombre": nombre == null ? null : nombre,
    "url": url == null ? null : url,
  

 };
}
导入'dart:convert';
Portada portadaFromMap(String str)=>Portada.fromMap(json.decode(str));
字符串portadaToMap(portadadata)=>json.encode(data.toMap());
波塔达级{
波塔达({
这个.json,
这是菜单,
这是我们的旗帜,
这个标签,
这是equipos,
这是menuIos,
这个.版本,,
这是维西奥尼斯,
});
列表json;
列表菜单;
横幅;
列出标签;
列出设备清单;
列表菜单;
字符串版本;
花椰菜;
工厂Portada.fromMap(MapJSON)=>Portada(
json:json[“json”]==null?null:List.from(json[“json”].map((x)=>json.fromMap(x)),
menu:json[“menu”]==null?null:List.from(json[“menu”].map((x)=>menu.fromMap(x)),
banners:json[“banners”]==null?null:banners.fromMap(json[“banners”]),
tags:json[“tags”]==null?null:List.from(json[“tags”].map((x)=>Tag.fromMap(x)),
equipos:json[“equipos”]==null?null:List.from(json[“equipos”].map((x)=>Equipo.fromMap(x)),
menuIos:json[“menu\u ios”]==null?null:List.from(json[“menu\u ios”].map((x)=>MenuIo.fromMap(x)),
版本:json[“版本”]==null?null:json[“版本”],
versionIos:json[“version\u ios”]==null?null:json[“version\u ios”],
);
映射toMap()=>{
“Json”:Json==null?null:List.from(Json.map((x)=>x.toMap()),
“menu”:menu==null?null:List.from(menu.map((x)=>x.toMap()),
“banners”:banners==null?null:banners.toMap(),
“tags”:tags==null?null:List.from(tags.map((x)=>x.toMap()),
“equipos”:equipos==null?null:List.from(equipos.map((x)=>x.toMap()),
“menu_ios”:menuIos==null?null:List.from(menuIos.map((x)=>x.toMap()),
“版本”:版本==空?空:版本,
“version_ios”:versionIos==null?null:versionIos,
};
}
班级横幅{
横幅({
这个,飞溅,
这是iPhone,
这个.main,,
这个,内科医生,
});
内部飞溅;
国际互联网;
主内;
内部;
工厂横幅。fromMap(Map json)=>横幅(
splash:json[“splash”]==null?null:Interna.fromMap(json[“splash”]),
splashiphone:json[“splashiphone”]==null?null:Interna.fromMap(json[“splashiphone”]),
main:json[“main”]==null?null:Interna.fromMap(json[“main”]),
interna:json[“interna”]==null?null:interna.fromMap(json[“interna”]),
);
映射toMap()=>{
“splash”:splash==null?null:splash.toMap(),
“splashiphone”:splashiphone==null?null:splashiphone.toMap(),
“main”:main==null?null:main.toMap(),
“interna”:interna==null?null:interna.toMap(),
};
}
实习班{
内部({
这是imagen,
这个链接,
});
字符串图像;
串链;
factory Interna.fromMap(Map json)=>Interna(
imagen:json[“imagen”]==null?null:json[“imagen”],
link:json[“link”]==null?null:json[“link”],
);
映射toMap()=>{
“imagen”:imagen==null?null:imagen,
“link”:link==null?null:link,
};
}
阶级装备{
装备({
这个身份证,
这个名字,
});
int-id;
字符串名称;
factory Equipo.fromMap(Map json)=>Equipo(
id:json[“id”]==null?null:json[“id”],
nombre:json[“nombre”]==null?null:json[“nombre”],
);
映射toMap()=>{
“id”:id==null?null:id,
“nombre”:nombre==null?null:nombre,
};
}
类Json{
Json({
这个身份证,
这个名字,
这个,标题,
这是permalink,
这个.内容,,
这是一段摘录,
这个日期,
这位作者,
这个,这个形象,,
这个,富恩特,
这个.缩略图,,
这是一个类别,
这个标签,
这是iPhone,
这是我的录影带,
});
int-id;
字符串标题;
字符串标题;
字符串permalink;
字符串内容;
字符串摘录;
日期时间日期;
字符串作者;
列表图像;
弦长;
字符串缩略图;
列出类别;
列出标签;
字符串内容;
字符串视频线;
工厂Json.fromMap(映射Json)=>Json(
id:json[“id”]==null?null:json[“id”],
title:json[“title”]==null?null:json[“title”],
titleint:json[“titleint”]==null?null:json[“titleint”],
permalink:json[“permalink”]==null?null:json[“permalink”],
content:json[“content”]==null?null:json[“content”],
超过