Json 参数类型';x';can';不能分配给参数类型';y';

Json 参数类型';x';can';不能分配给参数类型';y';,json,flutter,dart,Json,Flutter,Dart,这条线路有问题 Text(snapshot.data.isPause); 我不知道怎么修理它 -----------------------------------------代码------------------------------------------- MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( body: Center( child:

这条线路有问题

Text(snapshot.data.isPause);
我不知道怎么修理它

-----------------------------------------代码-------------------------------------------

MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
          body: Center(
        child: FutureBuilder<Post>(
            future: fetchPost(),
            builder: (context, snapshot) {
              if (snapshot.hasData)
                return Text(snapshot.data.isPause);
              else if (snapshot.hasError) {
                return Text("${snapshot.error}");
              }
              return CircularProgressIndicator();
            }),
      )),
    )
MaterialApp(
debugShowCheckedModeBanner:false,
家:脚手架(
正文:中(
孩子:未来建设者(
future:fetchPost(),
生成器:(上下文,快照){
if(snapshot.hasData)
返回文本(snapshot.data.isPause);
else if(snapshot.hasrerror){
返回文本(“${snapshot.error}”);
}
返回循环ProgressIndicator();
}),
)),
)


参数类型
x
无法分配给参数类型
y

您的
i因为
没有返回
String
,它需要返回
String
,因为
Text()
接受
String
,为了快速破解,您可以尝试下面的解决方案

Text(snapshot.data.isPause.toString());

isPause
返回的是什么?在我的手机中,应用程序说->键入“InternalLinkedHashMap”不是子类型“List”。你能发布
fetchPost()
方法吗?Future fetchPost()异步{final response=wait http.get(“API link”);if(response.statusCode==200){return post.fromJson(json.decode(response.body))}else{throw Exception('Failed to load…!');}}class Post{final bool autoPlay;final bool isPause;final List nowPlaying;final List queue;final double volume;Post({this.autoPlay,this.isPause,this.nowPlaying,this.queue,this.volume,});factory Post.fromJson(Map json){return Post(autoPlay:json['auto_play']、isPause:json['is_pause']、nowPlaying:json['now_playing']、queue:json['queue']、volume:json['volume']、);}}@Sadisha请更新您的问题。您甚至可以阅读注释代码吗?