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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.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
Api 颤振:快照不是';t显示数据_Api_Flutter_Listview_Snapshot - Fatal编程技术网

Api 颤振:快照不是';t显示数据

Api 颤振:快照不是';t显示数据,api,flutter,listview,snapshot,Api,Flutter,Listview,Snapshot,我使用get方法(API调用)创建了一个Listview构建器。API调用很好,因为我得到了响应。但在widget snapshot.data中显示为空。我无法解决这个问题,也不知道它为什么会这样。请有人帮帮我 API响应库 这是我的API调用代码 class服务{ 将来的getEducationInfo()异步{ 字符串url=“$baseAPIUrl/educations”; 字符串_token=wait SavedData().loadToken(); String authorizat

我使用get方法(API调用)创建了一个Listview构建器。API调用很好,因为我得到了响应。但在widget snapshot.data中显示为空。我无法解决这个问题,也不知道它为什么会这样。请有人帮帮我

API响应库

这是我的API调用代码

class服务{
将来的getEducationInfo()异步{
字符串url=“$baseAPIUrl/educations”;
字符串_token=wait SavedData().loadToken();
String authorization=“Bearer$\u token”;
var response=wait http.get(url,标题:{
“内容类型”:“应用程序/json”,
“接受”:“应用程序/json”,
“授权”:授权
});
打印('API${response.statusCode}\n API${json.decode(response.body)}');
如果(response.statusCode==200){
var jsonResponse=response.body;
var decoded=json.decode(jsonResponse);
返回解码['success']
.map((b)=>EducationInfo.fromJson(b))
.toList();
}否则{
抛出异常(“加载教育信息失败”);
}
}
}
这是我的模型。dart

//模型
课堂教学信息{
int-id;
线脱脂;
整数;
int regNumber;
年内;
字符串类型;
双cgpa;
双输出GPA;
字符串名称;
字符串组名;
字符串subjectName;
字符串boardName;
弦乐学院;
教育信息({
这个身份证,
这个是degreeName,
这个号码,
这个.regNumber,
今年,
这是一种.grade类型,
这个.cgpa,
这是GPA以外的地方,
这个名字,
这个.groupName,
这个.subjectName,
这个名字,
这个,学院名,
});
factory EducationInfo.fromJson(映射json){
返回教育信息(
id:json['user_id'],
degreeName:json['degree_name'],
rollNumber:json['roll_number'],
regNumber:json['registration_number'],
passingYear:json['passing_year'],
gradeType:json['grade_type'],
cgpa:json['cgpa'],
outofccpa:json['out\u of\u cgpa'],
分部名称:json['division'],
groupName:json['group_name'],
subjectName:json['subject_name'],
boardName:json['board'],
instituteName:json['institute_name'],
);
}
}
这是我的主要代码-

class Resume extends StatefulWidget {
  @override
  _ResumeState createState() => _ResumeState();
}

class _ResumeState extends State<Resume> {
  Future<List<EducationInfo>> furuteEducationInfo;

  @override
  void initState() {
    super.initState();
    furuteEducationInfo = APIService().getEducationInfo();
  }
  @override
  Widget build(BuildContext context) {
  return Scaffold(
      resizeToAvoidBottomPadding: false,
      appBar: AppBar(
        automaticallyImplyLeading: false,
        leading: IconButton(
          icon: Icon(
            Icons.arrow_back_ios,
          ),
          onPressed: () {
            Navigator.pop(context);
          },
        ),
        title: Text("Resume"),
      ),
      body: Align(
      child: FutureBuilder(
                            future: furuteEducationInfo,
                              builder: (context, snapshot) {
                                var educationInfo = snapshot.data;
                                if (snapshot.data == null) {
                                  return Text("No Data Available ");
                                } else if (snapshot.hasData) {
                                  return ListView.builder(
                                      scrollDirection: Axis.vertical,
                                      itemCount: educationInfo.length,
                                      itemBuilder: (context, index) {
                                        var eduInfo = educationInfo[index];
                                        print(
                                            "\nEducation Info ${educationInfo[index]}");
                                        return designedContainer(
                                            _width - 30,
                                            Padding(
                                              padding: EdgeInsets.all(5.0),
                                              child: Stack(
                                                children: [
                                                  Container(
                                                    child: Column(
                                                      children: [
                                                        detailsField(
                                                            "Degree Name",
                                                            "${_checkNull(eduInfo.degreeName)}"),
                                                      ],
                                                    ),
                                                  ),
                                                  Align(
                                                    alignment:
                                                        Alignment.topRight,
                                                    child: editButton(
                                                        Icons.add, "Delete",
                                                        () {
                                                      print("Delete");
                                                    }),
                                                  )
                                                ],
                                              ),
                                            ));
                                      });
                                } else {
                                  Text("Something Went to Wrong");
                                }
                              }),
       ),
    );
  }
class Resume扩展StatefulWidget{
@凌驾
_ResumeState createState()=>\u ResumeState();
}
类_ResumeState扩展了状态{
未来教育资讯;
@凌驾
void initState(){
super.initState();
furuteEducationInfo=APIService().getEducationInfo();
}
@凌驾
小部件构建(构建上下文){
返回脚手架(
resizeToAvoidBottomPadding:false,
appBar:appBar(
自动嵌入:false,
领先:IconButton(
图标:图标(
Icons.arrow\u back\u ios,
),
已按下:(){
Navigator.pop(上下文);
},
),
标题:正文(“简历”),
),
主体:对齐(
孩子:未来建设者(
未来:furuteEducationInfo,
生成器:(上下文,快照){
var educationInfo=snapshot.data;
如果(snapshot.data==null){
返回文本(“无可用数据”);
}else if(snapshot.hasData){
返回ListView.builder(
滚动方向:轴垂直,
itemCount:educationInfo.length,
itemBuilder:(上下文,索引){
var eduInfo=教育信息[索引];
印刷品(
“\n教育信息${educationInfo[index]}”);
返回指定容器(
_宽度-30,
填充物(
填充:所有边缘设置(5.0),
子:堆栈(
儿童:[
容器(
子:列(
儿童:[
详细信息字段(
“学位名称”,
“${u checkNull(eduInfo.degreeName)}”),
],
),
),
对齐(
对齐:
右上角,
孩子:编辑按钮(
Icons.add,“删除”,
() {
打印(“删除”);
}),
)
],
),
));
});
}否则{
文本(“出了问题”);
}
}),
),
);
}
这也是邮递员的截图-

在你的
教育中
//Model

class EducationInfo {
  int id;
  String degreeName;
  int rollNumber;
  int regNumber;
  int passingYear;
  String gradeType;
  double cgpa;
  double outOfCgpa;
  String divisionName;
  String groupName;
  String subjectName;
  String boardName;
  String instituteName;

  EducationInfo({
    this.id,
    this.degreeName,
    this.rollNumber,
    this.regNumber,
    this.passingYear,
    this.gradeType,
    this.cgpa,
    this.outOfCgpa,
    this.divisionName,
    this.groupName,
    this.subjectName,
    this.boardName,
    this.instituteName,
  });

  factory EducationInfo.fromJson(Map<String, dynamic> json) {
    return EducationInfo(
      id: json['user_id'],
      degreeName: json['degree_name'],
      rollNumber: json['roll_number'],
      regNumber: json['registration_number'],
      passingYear: json['passing_year'],
      gradeType: json['grade_type'],
      cgpa: json['cgpa'],
      outOfCgpa: json['out_of_cgpa'],
      divisionName: json['division'],
      groupName: json['group_name'],
      subjectName: json['subject_name'],
      boardName: json['board'],
      instituteName: json['institute_name'],
    );
  }
}
class Resume extends StatefulWidget {
  @override
  _ResumeState createState() => _ResumeState();
}

class _ResumeState extends State<Resume> {
  Future<List<EducationInfo>> furuteEducationInfo;

  @override
  void initState() {
    super.initState();
    furuteEducationInfo = APIService().getEducationInfo();
  }
  @override
  Widget build(BuildContext context) {
  return Scaffold(
      resizeToAvoidBottomPadding: false,
      appBar: AppBar(
        automaticallyImplyLeading: false,
        leading: IconButton(
          icon: Icon(
            Icons.arrow_back_ios,
          ),
          onPressed: () {
            Navigator.pop(context);
          },
        ),
        title: Text("Resume"),
      ),
      body: Align(
      child: FutureBuilder(
                            future: furuteEducationInfo,
                              builder: (context, snapshot) {
                                var educationInfo = snapshot.data;
                                if (snapshot.data == null) {
                                  return Text("No Data Available ");
                                } else if (snapshot.hasData) {
                                  return ListView.builder(
                                      scrollDirection: Axis.vertical,
                                      itemCount: educationInfo.length,
                                      itemBuilder: (context, index) {
                                        var eduInfo = educationInfo[index];
                                        print(
                                            "\nEducation Info ${educationInfo[index]}");
                                        return designedContainer(
                                            _width - 30,
                                            Padding(
                                              padding: EdgeInsets.all(5.0),
                                              child: Stack(
                                                children: [
                                                  Container(
                                                    child: Column(
                                                      children: [
                                                        detailsField(
                                                            "Degree Name",
                                                            "${_checkNull(eduInfo.degreeName)}"),
                                                      ],
                                                    ),
                                                  ),
                                                  Align(
                                                    alignment:
                                                        Alignment.topRight,
                                                    child: editButton(
                                                        Icons.add, "Delete",
                                                        () {
                                                      print("Delete");
                                                    }),
                                                  )
                                                ],
                                              ),
                                            ));
                                      });
                                } else {
                                  Text("Something Went to Wrong");
                                }
                              }),
       ),
    );
  }
  cgpa: json['cgpa'] ?? 0.0,
  outOfCgpa: json['out_of_cgpa'] ?? 0.0,
 (snapshot.hasData && snapshot.data.length == 0)
                ? Container(
                    child: Center(
                      child: Column(
                        mainAxisSize: MainAxisSize.max,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          Text("Congrats, No jobs asssigned!!!")
                        ],
                      ),
                    ),
                  )
                : (snapshot.hasData)
                    ? Container(
                        child: ListView.builder(
                   .....)