Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while rendering a CheckboxListTile widget in a Row widget in Flutter

Tags:

flutter

dart

So I have the following code:

            Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  CheckboxListTile(
                    title: Text("helo"),
                    controlAffinity: ListTileControlAffinity.leading,
                    value: true,
                    onChanged: null,

                  ),
                  Text(
                    "Forgot Password?",
                    style: TextStyle(color: Colors.blueGrey),
                  )
                ],
              ),

my aim is to create a "Remember me" check box and "Forgot Password?" in a row.

When I run this code it gives me the following error:

RenderBox was not laid out: RenderMergeSemantics#19dcc relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1785 pos 12: 'hasSize'
The relevant error-causing widget was Row lib\main.dart:106
═══════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════ 
RenderBox was not laid out:
_RenderColoredBox#cd072 relayoutBoundary=up14 
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1785 pos 12: 'hasSize'
The relevant error-causing widget was CheckboxListTile

Is there a way that I can get my desired output where the "Remember me" check box and "Forgot Password?" is in a Row?

Also, what is the problem with the current code?

like image 936
Codin' friends Avatar asked Jun 20 '26 18:06

Codin' friends


1 Answers

Wrap the CheckboxListTile in Expanded widget like shown below:

Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
      Expanded(
        child: CheckboxListTile(
          title: Text("helo"),
          controlAffinity: ListTileControlAffinity.leading,
          value: true,
          onChanged: null,

        ),
      ),
      Text(
        "Forgot Password?",
        style: TextStyle(color: Colors.blueGrey),
      )
    ],
  ),
like image 194
Ketan Ramteke Avatar answered Jun 23 '26 17:06

Ketan Ramteke