Question: New to flutter, can some one tells me whats wrong with below code[![enter image description here](https://i.stack.imgur.com/5b5lp.png)](https://i.stack.imgur.com/5b5lp.png)

```
  class GamePage extends StatelessWidget {
  int _row;
  int _column;

  GamePage(this._row,this._column);

  @override
  Widget build(BuildContext context) {
    return new Material(
      color: Colors.deepPurpleAccent,
      child:new Expanded(
          child:new GridView.count(crossAxisCount: _column,children: new List.generate(_row*_column, (index) {
        return new Center(
            child: new CellWidget()
        );
      }),) )

    );
  }
}

```

Attaching error screenshot.

Answer: 
You need to try using `Flex` Widget on that
Another simple example related to the error but with Expanded and ConstrainedBox :

The code:

```
Column(
  children:  [
    ConstrainedBox(
      child: Expanded(
        child: ...
      )
    )
  ]

```

The error message:

> 
> [...] Usually, this means that the Expanded widget has the wrong ancestor RenderObjectWidget. Typically, Expanded widgets are placed directly inside Flex widgets.
> The offending Expanded is currently placed inside a ConstrainedBox widget.
> 
> 
> 

Why the code is the code not working properly ?
In this example, Expanded must have the Column as direct Parent (which is a compatible parent type).

The solution:

```
Column(
  children:  [
   Expanded(
      child: ConstrainedBox(
        child: ...
      )
    )
  ]

```