当我水平翻转屏幕时,我希望有人能帮助我解决溢出问题.当我水平翻转屏幕时,我得到一个异常:
溢出的RenderFlex具有轴的方向.竖的
和我的模拟器上的提示符:
底部溢出194像素
现在由于这个异常,我try 添加一个"SingleChildScrollView"来解决这个问题,允许答案选项滚动并且不会溢出,但是滚动似乎不起作用,问题仍然存在.所以我希望有人能帮我解决这个问题,让我的测验页面也能水平运行而不会出错.非常感谢您的帮助!
quiz.dart
class Salvation extends StatefulWidget {
const Salvation({Key? key}) : super(key: key);
@override
State<Salvation> createState() => _SalvationState();
}
class _SalvationState extends State<Salvation> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Quiz')),
body: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return Column( children: [
Container(
height: constraints.maxHeight / 4,
child: Padding(padding: EdgeInsets.fromLTRB(12, 12, 12, 8),
child: Align(
alignment: Alignment.topLeft,
child: Text('Question',
style: TextStyle(fontSize: 20.0,)),))
),
Visibility(// visible: ,
child: Container(
height: constraints.maxHeight / 4,
child: Padding(padding: EdgeInsets.fromLTRB(12, 3, 12, 6),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Color.fromRGBO(118, 60, 51, 0.5),
),
width: double.infinity,
child: Padding(padding: EdgeInsets.fromLTRB(12, 8, 12, 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Example/Image Box',
style: TextStyle(fontSize: 17.0,)),
// RichText(text: text)
Text('Hello there',
style: TextStyle(fontSize: 15.0,)),
],),
)),
),
),),
SingleChildScrollView(
child:Container(
height: constraints.maxHeight / 2,
color: const Color.fromRGBO(155, 205, 255, 0.8),
child: Padding(padding: const EdgeInsets.fromLTRB(12, 12, 12, 20),
child: Column(children: [
Padding(padding: EdgeInsets.fromLTRB(0, 0, 0, 6),
child: ListTile(
title: Text('Option A'),
tileColor: const Color.fromRGBO(6, 145, 248, 1),
shape: RoundedRectangleBorder(
side: const BorderSide(color: Colors.black, width: 10),
borderRadius: BorderRadius.circular(5)),
onTap: () {},
),),
Padding(padding: EdgeInsets.fromLTRB(0, 0, 0, 6),
child: ListTile(
title: Text('Option B'),
tileColor: const Color.fromRGBO(6, 145, 248, 1),
shape: RoundedRectangleBorder(
side: const BorderSide(color: Colors.black, width: 10),
borderRadius: BorderRadius.circular(5)),
onTap: () {},
),),
Padding(padding: EdgeInsets.fromLTRB(0, 0, 0, 6),
child: ListTile(
title: Text('Option C'),
tileColor: const Color.fromRGBO(6, 145, 248, 1),
shape: RoundedRectangleBorder(
side: const BorderSide(color: Colors.black, width: 10),
borderRadius: BorderRadius.circular(5)),
onTap: () {},
onLongPress: () {},
),),
Padding(padding: EdgeInsets.fromLTRB(0, 0, 0, 6),
child: ListTile(
title: Text('Option D'),
tileColor: const Color.fromRGBO(6, 145, 248, 1),
shape: RoundedRectangleBorder(
side: const BorderSide(color: Colors.black, width: 10),
borderRadius: BorderRadius.circular(5)),
onTap: () {},
),),
]),
),
),
)],
);
},
),
);
}
}
编辑:此问题已得到回答,但解决方案产生了另一个问题.所以,如果你想帮助解决this question个问题,或者你遇到了同样的问题,请点击链接.:)