Flutter 颤振:右溢出35像素
我正在我的颤振应用程序中创建一个MCQ页面。所有问题和选项都来自我的API。但由于这个问题,问题部分并没有完全呈现出来。我有两个请求,如何消除此错误以及如何将选项显示为单选按钮。到目前为止,它们看起来像所附的图像Flutter 颤振:右溢出35像素,flutter,dart,flutter-layout,Flutter,Dart,Flutter Layout,我正在我的颤振应用程序中创建一个MCQ页面。所有问题和选项都来自我的API。但由于这个问题,问题部分并没有完全呈现出来。我有两个请求,如何消除此错误以及如何将选项显示为单选按钮。到目前为止,它们看起来像所附的图像 Widget build(BuildContext context) { final QuizProvider quizP = Provider.of<QuizProvider>(context); return Container(child
Widget build(BuildContext context) {
final QuizProvider quizP = Provider.of<QuizProvider>(context);
return Container(child: Column(
children:<Widget> [
Padding(
padding: const EdgeInsets.only(left: 25.0, top: 10.0, bottom: 10.0, right: 10.0),
child: Row(
children: [
Column(
children: [
Html(
data: quizP.quizzes[0].getQuestions[widget.questionID].content,)
],
),
],
),
),
quizP.quizzes[0].getQuestions.length == null
? Container(
child: Center(child: Text("Opps , Looks like we don't have any questions"),),
)
: ListView.builder(
itemCount: quizP.quizzes[0].getQuestions[widget.questionID].getanswers.length,
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemBuilder: (context, itemCount) {
return RadioListTile(
value: quizP.quizzes[0].getQuestions[widget.questionID].getanswers[itemCount].id,
groupValue: _selectedValue,
onChanged: (answer){
setState(() {
_selectedValue = answer;
// if(quizP.quizzes[0].getQuestions[widget.questionID].getanswers[itemCount].correct== false){
_selectedValue = _selectedValue+1;
// _incorrectQuestion = 'hi';//quizP.quizzes[0].getQuestions[widget.questionID].id.toString();
// }
});
},
title: Text("${ quizP.quizzes[0].getQuestions[widget.questionID].getanswers[itemCount].content}"),
);
},
),
],
),
);
飞镖
import 'dart:convert';
Quiz quizFromJson(String str) => Quiz.fromJson(json.decode(str));
String quizToJson(Quiz data) => json.encode(data.toJson());
class Quiz {
Quiz({
this.id,
this.title,
this.description,
this.url,
this.category,
this.randomOrder,
this.passMark,
this.draft,
this.durationtest,
this.getQuestions,
});
int id;
String title;
String description;
String url;
int category;
bool randomOrder;
int passMark;
bool draft;
String durationtest;
List<GetQuestion> getQuestions;
factory Quiz.fromJson(Map<String, dynamic> json) => Quiz(
id: json["id"],
title: json["title"],
description: json["description"],
url: json["url"],
category: json["category"],
randomOrder: json["random_order"],
passMark: json["pass_mark"],
draft: json["draft"],
durationtest: json["durationtest"],
getQuestions: List<GetQuestion>.from(json["get_questions"].map((x) => GetQuestion.fromJson(x))),
);
Map<String, dynamic> toJson() => {
"id": id,
"title": title,
"description": description,
"url": url,
"category": category,
"random_order": randomOrder,
"pass_mark": passMark,
"draft": draft,
"durationtest": durationtest,
"get_questions": List<dynamic>.from(getQuestions.map((x) => x.toJson())),
};
}
class GetQuestion {
GetQuestion({
this.id,
this.content,
this.getanswers,
});
int id;
String content;
List<Getanswer> getanswers;
factory GetQuestion.fromJson(Map<String, dynamic> json) => GetQuestion(
id: json["id"],
content: json["content"],
getanswers: List<Getanswer>.from(json["getanswers"].map((x) => Getanswer.fromJson(x))),
);
Map<String, dynamic> toJson() => {
"id": id,
"content": content,
"getanswers": List<dynamic>.from(getanswers.map((x) => x.toJson())),
};
}
class Getanswer {
Getanswer({
this.id,
this.content,
this.correct,
this.questionId,
});
int id;
Content content;
bool correct;
int questionId;
factory Getanswer.fromJson(Map<String, dynamic> json) => Getanswer(
id: json["id"],
content: contentValues.map[json["content"]],
correct: json["correct"],
questionId: json["question_id"],
);
Map<String, dynamic> toJson() => {
"id": id,
"content": contentValues.reverse[content],
"correct": correct,
"question_id": questionId,
};
}
enum Content { A, B, C, D }
final contentValues = EnumValues({
"A": Content.A,
"B": Content.B,
"C": Content.C,
"D": Content.D
});
class EnumValues<T> {
Map<String, T> map;
Map<T, String> reverseMap;
EnumValues(this.map);
Map<T, String> get reverse {
if (reverseMap == null) {
reverseMap = map.map((k, v) => new MapEntry(v, k));
}
return reverseMap;
}
}
试试这个
Padding(
padding: const EdgeInsets.only(left: 25.0, top: 10.0, bottom: 10.0, right: 10.0),
child: Row(
children: [
Expanded(
child: Html(
data: quizP.quizzes[0].getQuestions[widget.questionID].content,)
),
],
),
),