A.A
A.A

Reputation: 4091

Flutter Text overflow in row and column

In the following code

import 'package:flutter/material.dart';

final Color darkBlue = Color.fromARGB(255, 18, 32, 47);

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: MyWidget(),
        ),
      ),
    );
  }
}

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final text = Text(
        'When large fortunes fall into the hands of some people, they become strong in the light of it, and in the shadow of strength and wealth they dream that they can live out of their homeland and be happy and proud, they will soon realize that they have made mistakes, and the greatness of every nation On the ruins of his homeland and cease!',
        style: Theme.of(context).textTheme.headline4);

    return Column(
      mainAxisSize: MainAxisSize.min,
      mainAxisAlignment: MainAxisAlignment.start,
      children: [
        Row(
          children: [
            Column(
              children: [
                text,
              ],
            ),
          ],
        )
      ],
    );
  }
}

I have a Text widget in a Column in Row in another Column , As text is in Row it is single row and overflowed, I want to make it multiline to I wrap it with Flexible

    return Column(
      mainAxisSize: MainAxisSize.min,
      mainAxisAlignment: MainAxisAlignment.start,
      children: [
        Row(
          children: [
            Column(
              children: [
                Flexible(child: text),
              ],
            ),
          ],
        )
      ],
    );

What is wrong here? Why I have RenderFlex children have non-zero flex but incoming height constraints are unbounded. ?

Upvotes: 0

Views: 311

Answers (1)

Evgeniy Trubilo
Evgeniy Trubilo

Reputation: 97

You must wrap column with flexible, not text itself. Please try this. It's working for me.

Column(
    mainAxisSize: MainAxisSize.min,
    mainAxisAlignment: MainAxisAlignment.start,
    children: [
      Row(
        children: [
          Flexible(child: Column(
            children: [
              text
            ],
          ),)
        ],
      )
    ],
  )

Upvotes: 1

Related Questions