嘿,我想不出一种方法来修复容器内的文本,它会破坏线条并自行扩展容器。我已经寻找解决方案,但扩展和灵活不起作用。有人可以帮助我吗? :)
这是问题的图片:
myContainer({required String title}) {
return Padding(
padding: const EdgeInsets.only(bottom: 5.0),
child: SizedBox(
child: Padding(
padding: const EdgeInsets.only(top: 8.0),
child: GestureDetector(
onTap: () {
print("Das hat funktioniert");
},
child: Container(
decoration: BoxDecoration(
color: const Color.fromRGBO(86, 89, 94, 1),
borderRadius: BorderRadius.circular(15.0),
border: Border.all(
color: Color.fromRGBO(255, 128, 0, 1),
width: 2,
),
),
padding: EdgeInsets.only(top: 10, bottom: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(children: [
Padding(
padding: const EdgeInsets.only(
left: 12.0, top: 14, bottom: 14),
child: Container(
child: Text(
title,
style: TextStyle(
color: Colors.white,
fontSize: 22,
fontWeight: FontWeight.w400),
),
),
),
])
])),
),
)));
非常感谢!
将您的文本小部件添加到 Expandable 中:
Padding(
padding: const EdgeInsets.only(bottom: 5.0),
child: SizedBox(
child: Padding(
padding: const EdgeInsets.only(top: 8.0),
child: GestureDetector(
onTap: () {
print("Das hat funktioniert");
},
child: Container(
decoration: BoxDecoration(
color: const Color.fromRGBO(86, 89, 94, 1),
borderRadius: BorderRadius.circular(15.0),
border: Border.all(
color: Color.fromRGBO(255, 128, 0, 1),
width: 2,
),
),
padding: EdgeInsets.only(top: 10, bottom: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Row(children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(
left: 12.0, top: 14, bottom: 14),
child: Container(
child: Text(
'Add your long title here after Expanded it does not give any type of error',
style: TextStyle(
color: Colors.white,
fontSize: 22,
fontWeight: FontWeight.w400),
),
),
),
),
]),
)
],
),
),
),
),
),
),