text
stringlengths 1
372
|
|---|
),
|
],
|
);
|
<code_end>
|
another way is to wrap the column in a flexible widget
|
and specify a flex factor. in fact,
|
the expanded widget is equivalent to the flexible widget
|
with a flex factor of 1.0, as its source code shows.
|
to further understand how to use the flex widget in flutter layouts,
|
check out this 90-second widget of the week video
|
on the flexible widget.
|
further information:
|
the resources linked below provide further information about this error.
|
<topic_end>
|
<topic_start>
|
‘renderbox was not laid out’
|
while this error is pretty common,
|
it’s often a side effect of a primary error
|
occurring earlier in the rendering pipeline.
|
what does the error look like?
|
the message shown by the error looks like this:
|
how might you run into this error?
|
usually, the issue is related to violation of box constraints,
|
and it needs to be solved by providing more information
|
to flutter about how you’d like to constrain the widgets in question.
|
you can learn more about how constraints work
|
in flutter on the understanding constraints page.
|
the RenderBox was not laid out error is often
|
caused by one of two other errors:
|
<topic_end>
|
<topic_start>
|
‘vertical viewport was given unbounded height’
|
this is another common layout error you could run into
|
while creating a UI in your flutter app.
|
what does the error look like?
|
the message shown by the error looks like this:
|
how might you run into this error?
|
the error is often caused when a ListView
|
(or other kinds of scrollable widgets such as GridView)
|
is placed inside a column. a ListView takes all
|
the vertical space available to it,
|
unless it’s constrained by its parent widget.
|
however, a column doesn’t impose any constraint
|
on its children’s height by default.
|
the combination of the two behaviors leads to the failure of
|
determining the size of the ListView.
|
<code_start>
|
widget build(BuildContext context) {
|
return center(
|
child: column(
|
children: <widget>[
|
const Text('Header'),
|
ListView(
|
children: const <widget>[
|
ListTile(
|
leading: Icon(Icons.map),
|
title: Text('Map'),
|
),
|
ListTile(
|
leading: Icon(Icons.subway),
|
title: Text('Subway'),
|
),
|
],
|
),
|
],
|
),
|
);
|
}
|
<code_end>
|
how to fix it?
|
to fix this error, specify how tall the ListView should be.
|
to make it as tall as the remaining space in the column,
|
wrap it using an expanded widget (as shown in the following example).
|
otherwise, specify an absolute height using a SizedBox
|
widget or a relative height using a flexible widget.
|
<code_start>
|
widget build(BuildContext context) {
|
return center(
|
child: column(
|
children: <widget>[
|
const Text('Header'),
|
expanded(
|
child: ListView(
|
children: const <widget>[
|
ListTile(
|
leading: Icon(Icons.map),
|
title: Text('Map'),
|
),
|
ListTile(
|
leading: Icon(Icons.subway),
|
title: Text('Subway'),
|
),
|
],
|
),
|
),
|
],
|
),
|
);
|
}
|
<code_end>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.