Reputation: 2274
I have a simple Widget
with a Row
and Text
inside of it. If the Text
is longer it should simply go in the next line but right now it is staying in one line and giving me an overflow
:
This is my code for it:
class HintKeyPoint extends StatelessWidget {
final String text;
const HintKeyPoint({
required this.text,
});
@override
Widget build(BuildContext context) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: scaleWidth(10),
),
Container(
height: scaleWidth(16),
width: scaleWidth(16),
decoration: BoxDecoration(
color: AppColors.primaryLight, shape: BoxShape.circle),
),
SizedBox(
width: scaleWidth(10),
),
Text(
text,
style: AppTextStyles.h7,
),
],
);
}
}
Why is the Text
not taking the vertical space? What am I doing wrong here?
Upvotes: 0
Views: 115
Reputation: 1744
You need to wrap the Text Widget
with Expanded Widget
.
Example:
Expanded(
child: Text(
"lorem10 lorem10 lorem10lorem10lorem10lorem10lorem10 lorem10lorem10lorem10lorem10lorem10 lorem10lorem10lorem10lorem10lorem10 lorem10",
),
),
Upvotes: 1