Search code examples
flutterdarttextrow

Flutter text is not wrapping inside Row


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:

enter image description here

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?


Solution

  • Wrap Text widget with Expanded.