问题描述
这里我从 API 中获取字符串值。该字符串是使用 Provider 类收集的,而 Access 是使用消费者收集的。它正确地穿了绳子。但是那个字符串的数字一直在变化,我忍不住在这里附上了这个问题的视频。
文本小部件:
Text(
mcq.selectedMCQ.questionTitle,style: TextStyle(fontSize: 20),),
供应商:
未来 getFetchQuestion(String questionId) async{
var url = Uri.parse('${BaseUrl.url}/MobileAPI/getQuestionByID/$questionId');
var response = await http.get(
url,headers: {
"Content-Type": "application/json",},);
if (response.statusCode == 200) {
final responseData = json.decode(response.body);
MCQ result =
MCQ.fromJson(responseData);
_selectedMCQ = result;
notifyListeners();
}
}
MCQ 类:
late String mcqQuestionId;
late String moduleId;
late String mcqId;
late String type;
late String step;
late int questionNumber;
late String questionTitle;
late String status;
late List<MCQAnswer> mcqAnswerList;
MCQ({
required this.mcqQuestionId,required this.moduleId,required this.mcqId,required this.type,required this.step,required this.questionNumber,required this.questionTitle,required this.status,required this.mcqAnswerList,});
factory MCQ.fromJson(dynamic json) {
var mcqAnswerList = json[0]['QuestionList'] as List;
List<MCQAnswer> loadedAnswerList =
mcqAnswerList.map((e) => MCQAnswer.fromJson(e)).toList();
return MCQ(
mcqQuestionId: json[0]['_id'].toString(),moduleId: json[0]['moduleID'],mcqId: json[0]['mcqID'],type: json[0]['type'],step: json[0]['step'],questionNumber: json[0]['no'],questionTitle: json[0]['questionTitle'],status: json[0]['status'],mcqAnswerList: loadedAnswerList,);
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)