I am writing code for a web application, To make it dynamic I am creating the following code. Now when I use the markdown as Expanded the issue starts . I have tried To make things expanded now its going beyond my understanding. I am asking help from the community to solve this and enlighten me. I am attaching the code snippet for better understanding.
Column(
children: [
Expanded(
child: Row(
children: [
Expanded(
flex: 5,
child:
Container(), //rest of the container code container a singlechild scrollview as child
),
Expanded(
flex: 2,
child: Container(
padding: const EdgeInsets.all(defaultPadding),
decoration: BoxDecoration(
color: colorScheme.secondary,
borderRadius: BorderRadius.circular(20)),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
child: Markdown(
data:
data)), //When I am trying to use this the problem occurs
],
),
),
))
],
),
)
],
),
You can run the same thing . I am facing error of vertical viewport has given unbounded height. Now I have tried devtool also but cannot understand what I need to do to solve it???? More over I will add some other widgets on top of that markdown. Please help me by solving it.
2
Answers
Since you are using
SingleChildScrollView
, it’s content has unbounded height. And you are placingColumn
as it’s child, usingExpanded
for thatColumn
can’t decide the height of the child.You must set the height of
Markdown
or wrap it withFlexible
, not withExpanded
.Since you are using an
Expanded
widget inside the child of the mainColumn
, you cannot again give itSingleChildScrollView
as a child as both their sizes are unbounded hence the error. The solution is simply removing theSingleChildScrollChild
widget as the parentExpanded
widget already takes care of the vertical expansion capability as shown below:Hope this helps and Happy coding!!😊