如何解决停止在文本小部件的循环中更改字符串中的数字
这里我从 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 举报,一经查实,本站将立刻删除。