'ListView and Expanded not work in flutter

I need help to solve this problem. The expanded renders the child but does not expand.

return Scaffold(
  body: ListView(
    children:  [

      _HomeBody(child: child,)

    ],
  )
);

_HomeBody

return Container(
  width: MediaQuery.of(context).size.width,
  height: MediaQuery.of(context).size.height
  child: Column(
    children: [
      AppBarMenu(),
      Expanded(child: child), // A RenderFlex overflowed by 1246 pixels on the bottom. 
      Footer()
    ],
  ),
);

Error Output

══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during layout:
A RenderFlex overflowed by 1246 pixels on the bottom.
The relevant error-causing widget was:
Column
lib\…\views\home_view.dart:19
The overflowing RenderFlex has an orientation of Axis.vertical.
The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and
black striped pattern. This is usually caused by the contents being too big for the RenderFlex.
Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the
RenderFlex to fit within the available space instead of being sized to their natural size.
This is considered an error condition because it indicates that there is content that cannot be
seen. If the content is legitimately bigger than the available space, consider clipping it with a
ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex,
like a ListView.
The specific RenderFlex in question is: RenderFlex#90f9f OVERFLOWING:
  needs compositing
  creator: Column ← ConstrainedBox ← Container ← HomeView ← Builder ←
    RepaintBoundary-[GlobalKey#97a2c] ← IgnorePointer ← AnimatedBuilder ← FractionalTranslation ←
    SlideTransition ← AnimatedBuilder ← RepaintBoundary ← ⋯
  parentData: <none> (can use size)
  constraints: BoxConstraints(w=966.0, h=840.0)
  size: Size(966.0, 840.0)
  direction: vertical
  mainAxisAlignment: start
  mainAxisSize: max
  crossAxisAlignment: start
  textDirection: ltr
  verticalDirection: down

HomeLayout code

child code



Solution 1:[1]

You can't have Expanded inside of a scrolling view (SignleChildScrollView, ListView, etc..)

cause like this you are telling the child of the expanded to take of the whole vertical space allowed to you, and the scroll view can allow infinite vertical space, so in a nutshell, you are telling the child of the Expanded take the size of infinity. hope this clarifies the error

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 omar hatem