skip to Main Content

I have some text, which if long, is causing the renderflex on the right error.
I have tried wrapping the long text in Expanded – this makes no difference. The compiler suggests the first Row is to blame, but I cannot wrap this in Expanded because of the Incorrect use of ParentDataWidget error.

return
  Container(
    padding: EdgeInsets.only(top: 1, bottom: 5),
    width: MediaQuery.of(context).size.width,
    color: Colors.white,
    child:
    Row(. /** THIS IS THE ROW THE COMPILER SAYS IS AT FAULT - CANNOT WRAP IN EXPANDED **/
      children: [
          Column(
          children: [
            Row(
            children: [
              Column (
                children: [
                  Image.asset(summary.getIconPath(),
                      width: 100,
                      errorBuilder: (ctx, error, stackTrace) =>
                          Text('Image Error')
                  ),
                ],
              ),

               Column (
                 children: [
                   Row(
                     mainAxisSize: MainAxisSize.min,
                     children: [
                       Text(summary.time.toString() + " - " + summary.tempMax.toString()),
                     ],
                   ),
                 ]
               ),
              ]
              ),
            Row(
               children: [
                 Text(summary.description ?? ""), /** THIS IS THE TEXT WHICH IF LONG CASES THE ERROR - WRAPPING IN. EXPANDED DOESN"T WORK **/
               ],
             ),
          ],
        ),
      ],
    ),
  );

2

Answers


  1. I removed unnecessary Rows and wrapped text with Flexible widget.

    Container(
            padding: const EdgeInsets.only(top: 1, bottom: 5),
            width: MediaQuery.of(context).size.width,
            color: Colors.white,
            child: Column(
              children: [
                Row(children: [
                  Column(
                    children: [
                      // Image.asset(summary.getIconPath(),
                      //     width: 100,
                      //     errorBuilder: (ctx, error, stackTrace) =>
                      //         Text('Image Error')
                      // ),
                      Container(
                        width: 100,
                      )
                    ],
                  ),
                  const Column(children: [
                    Row(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        Text(
                            "summary.time.toString() - summary.tempMax.toString()"),
                      ],
                    ),
                  ]),
                ]),
                const Flexible(
                  child: Text(
                    "sadaass d ssasdad asdas sadsas sasdasasdsa ss das sas adsaasaddsasa sss ad aas ssd  sadssdd d sdsdasd sadasdadsads asdadsdasdsa asddaasddsasa sasdsads sddsadsdaas sass as  asdaasdssasa d adsdsdadaddaddsaaadaddsasd dsaasdadsasd sadasdasdasd asddas asdasd asdasd asdasd",
                    softWrap: true,
                  ),
                ),
              ],
            ),
          )
    

    this is working.

    Login or Signup to reply.
  2. Container(
     constraints: BoxConstraints(
     maxWidth:  MediaQuery.of(context).size.width),
     child: const Text(summary.description ?? ""),
       ),
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search