Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何显示wordpress内容图像api_Wordpress_Api_Flutter - Fatal编程技术网

如何显示wordpress内容图像api

如何显示wordpress内容图像api,wordpress,api,flutter,Wordpress,Api,Flutter,我想在我的Flitter应用程序中显示图像内容。我使用WordPressAPI。 我使用这个类来显示featuredmedia、标题和内容 Post.fromJson(Map<String, dynamic> json) : title = json['title']["rendered"], excerpt = json['excerpt']["rendered"], image = json["_embedded"]['wp:featuredmedia'][

我想在我的Flitter应用程序中显示图像内容。我使用WordPressAPI。 我使用这个类来显示featuredmedia、标题和内容

 Post.fromJson(Map<String, dynamic> json)
  : title = json['title']["rendered"],
    excerpt = json['excerpt']["rendered"],
    image = json["_embedded"]['wp:featuredmedia'][0]["media_details"]
        ["sizes"]["medium"]["source_url"],
    date = json['date'],
    content = json['content']["rendered"],
      id = json['id'];
Post.fromJson(映射json)
:title=json['title'][“呈现”],
摘录=json[“摘录”][“呈现”],
image=json[“\u嵌入”]['wp:featuredmedia'][0][“媒体\u详细信息”]
[“大小”][“中等”][“源url”],
date=json['date'],
content=json['content'][“rendered”],
id=json['id'];
这是wordpress的内容

“内容”:{ “呈现”:“首相警告议员们,他们试图阻止无协议脱欧,这将损害他与欧盟达成协议的机会。

\n鲍里斯·约翰逊说,英国将“要么做,要么死”地离开欧盟10月31日——促使一些议员采取行动阻止英国在未达成协议的情况下离开。

\n但他表示,议员们越是试图阻止无协议脱欧,“我们就越有可能最终陷入这种局面。”\n这是在首相宣布他将在9月和10月暂停议会五周后发生的。

\n约翰逊先生说,这是为了允许政府举行女王演讲,并概述其“非常激动人心的议程”为了未来。

\n但批评人士声称,他的意图是阻止下议院采取任何行动来阻止不交易。

\nhttps://iraqmedianews.com/wp-content/uploads/2019/08/file-20181002-85614-vu0p6l-300x205.jpg\“alt=\”\“宽度=\“300\”高度=“205\”srcset=“300w、768w、926w\”尺寸=\“(最大宽度:300px)100vw、300px\”/>

\n”, “受保护”:错误
},

您可以使用
Image.network
在获得指向该图像的链接后显示该图像

示例代码和解决方案:

    String imageUrl,rawString,i,j;
    [...]
    // At some point of your code
    rawString  = json['content']["rendered"];   
    for(int i=0;i<rawString.length;i++) if(rawString[i]=='=' && rawString[i-1]=='t' && rawString[i-2]=='e' && rawString[i-3]=='s' && rawString[i-4]=='c' && rawString[i-5]=='r' && rawString[i-6]=='s') 
for(j=i+3;(rawString[i]=='.' && (rawString.substring(j,j+4)=="jpg")||rawString.substring(j,j+4)=="png");j++)
   imageUrl = rawString.substring(i,j+4);
    [...]
    // The place where you want to display your widget
    Image.network(
      imageUrl, // Can add more attributes 
    );
stringimageurl,rawString,i,j;
[...]
//在代码的某个点上
rawString=json['content'][“rendered”];

对于(int i=0;iThanks,但我认为还有另一种简单的方法,我已将链接添加到帮助您回答问题的包中,使其适合于获得正确答案。我尝试使用此方法,但不使用工作Image.network(parse(widget.data.content).body.innerHtml)尝试使用上述解决方案。独立于html包的代码我附加了另外两个包的链接。它们肯定会在某种程度上帮助您使用Wordpress。