Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get an error `Failed assertion: line 1687 pos 12: 'hasSize'` when render ListTile inside `Row`

Tags:

flutter

I have below code in flutter.

Widget build(BuildContext context) {
    return Center(
      child: Card(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            Row(
              children: <Widget>[
                SizedBox(
                    height: 100,
                    child: ListTile(
                      leading: IconButton(
                        iconSize: 30,
                        icon: roundImage(post.userPicture, Icon(Icons.person)),
                        onPressed: () {},
                      ),
                      subtitle: Text(this.post.message),
                    )),
              ],
            ),
          ],
        ),
      ),
    );
  }

But I get this error:

════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderPhysicalShape#7713c relayoutBoundary=up3
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1687 pos 12: 'hasSize'
The relevant error-causing widget was
    Card 

I have added SizedBox in the Row but it still complains about hasSize error. How can I solve this issue?

like image 900
Joey Yi Zhao Avatar asked May 17 '20 06:05

Joey Yi Zhao


2 Answers

It's not clear what you're trying to achieve, but instead of using SizedBox you can try wrapping inside Expanded or Flexible widgets.

like image 71
dhanasekar Avatar answered Oct 01 '22 00:10

dhanasekar


Add Flexible

Row(
    children: [
      new Flexible(
        child: new TextField(
          decoration: const InputDecoration(helperText: "Enter App ID"),
          style: Theme.of(context).textTheme.body1,
        ),
      ),
    ],
  ),
like image 24
Mehran Bagvand Avatar answered Oct 01 '22 02:10

Mehran Bagvand