我连续创建了 3 个三个容器,它在模拟器上运行良好,但是当我在我的安卓手机上运行应用程序时,它给了我right overflowed by 20 pixels
错误。
我找到了包装它的解决方案,SingleChildScrollView
但我不想滚动我的屏幕我想在不滚动的情况下修复它。
这是模拟器上的输出
代码:
Padding(
padding: EdgeInsets.only(top: 100),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
new Container(
decoration: BoxDecoration(
color: Colors.pink,
borderRadius: BorderRadius.all(Radius.circular(10))),
height: 100,
width: 180,
child: Padding(
padding: EdgeInsets.only(top: 15),
child: Center(
child: Column(children: <Widget>[
Text("Last total working hours",
style: TextStyle(
color: fontcolor,
fontSize: headfontsize,
fontFamily: fontFamily)),
Text(totalWorkingHours(),
style: TextStyle(
color: fontcolor,
fontSize: remainingtextfontsize,
fontFamily: fontFamily)),
Text("Hours",
style: TextStyle(
color: fontcolor,
fontSize: remainingtextfontsize,
fontFamily: fontFamily)),
]),
)),
),
new Container(
decoration: BoxDecoration(
color: Color(int.parse(presentcolor)),
borderRadius: BorderRadius.all(Radius.circular(10))),
height: 100,
width: 100,
child: Padding(
padding: EdgeInsets.only(top: 15),
child: Center(
child: Column(children: <Widget>[
Text("Presents",
style: TextStyle(
color: fontcolor,
fontSize: headfontsize,
fontFamily: fontFamily)),
Text("20",
style: TextStyle(
color: fontcolor,
fontSize: remainingtextfontsize,
fontFamily: fontFamily)),
]),
)),
),
new Container(
decoration: BoxDecoration(
color: Color(int.parse(absentcolor)),
borderRadius: BorderRadius.all(Radius.circular(10))),
height: 100,
width: 100,
child: Padding(
padding: EdgeInsets.only(top: 15),
child: Center(
child: Column(children: <Widget>[
Text("Absents",
style: TextStyle(
color: fontcolor,
fontSize: headfontsize,
fontFamily: fontFamily)),
Text("0",
style: TextStyle(
color: fontcolor,
fontSize: remainingtextfontsize,
fontFamily: fontFamily)),
]),
)),),
],
)),
更新: 感谢您提供的所有解决方案,我尝试了它们并得到了相同的输出,这是快照
但我想要容器之间的空间,我正在使用spacer
它,但它再次干扰了容器的宽度。
这是更新的代码
Container(
width: MediaQuery.of(context).size.width,
child: FittedBox(
// Scales down if size is not enough.
fit: BoxFit.scaleDown,
child: Padding(
padding: EdgeInsets.only(top: 100),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
new Container(
decoration: BoxDecoration(
color: Colors.pink,
borderRadius:
BorderRadius.all(Radius.circular(10))),
height: 100,
width: 180,
child: Padding(
padding: EdgeInsets.only(top: 15),
child: Center(
child: Column(children: <Widget>[
Text("Last total working hours",
style: TextStyle(
color: fontcolor,
fontSize: headfontsize,
fontFamily: fontFamily)),
Text(totalWorkingHours(),
style: TextStyle(
color: fontcolor,
fontSize: remainingtextfontsize,
fontFamily: fontFamily)),
Text("Hours",
style: TextStyle(
color: fontcolor,
fontSize: remainingtextfontsize,
fontFamily: fontFamily)),
]),
)),
),
new Container(
decoration: BoxDecoration(
color: Color(int.parse(presentcolor)),
borderRadius:
BorderRadius.all(Radius.circular(10))),
height: 100,
width: 100,
child: Padding(
padding: EdgeInsets.only(top: 15),
child: Center(
child: Column(children: <Widget>[
Text("Presents",
style: TextStyle(
color: fontcolor,
fontSize: headfontsize,
fontFamily: fontFamily)),
Text("20",
style: TextStyle(
color: fontcolor,
fontSize: remainingtextfontsize,
fontFamily: fontFamily)),
]),
)),
),
new Container(
decoration: BoxDecoration(
color: Color(int.parse(absentcolor)),
borderRadius:
BorderRadius.all(Radius.circular(10))),
height: 100,
width: 100,
child: Padding(
padding: EdgeInsets.only(top: 15),
child: Center(
child: Column(children: <Widget>[
Text("Absents",
style: TextStyle(
color: fontcolor,
fontSize: headfontsize,
fontFamily: fontFamily)),
Text("0",
style: TextStyle(
color: fontcolor,
fontSize: remainingtextfontsize,
fontFamily: fontFamily)),
]),
)),
),
],
)),
)),
请帮我解决这个问题。