I'm trying to render widgets on Stack and there is enum and with that state I want to render different widgets except for background image like this.
.
Stack looks like this now
new Stack(
children: <Widget>[
new Image.network(
'https://images.unsplash.com/photo-1536226078409-fb25e1ed23b9?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=51ea5572bb7bbdf19e616f3550fccd9d&auto=format&fit=crop&w=500&q=60',
fit: BoxFit.cover,
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
),
// render widgets here.
],
),
Then I want to render based on the enum state.
So, code would be like this.
List<Widget> listOfWidget() {
return [];
}
new Stack(
children: <Widget>[
new Image.network(
'https://images.unsplash.com/photo-1536226078409-fb25e1ed23b9?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=51ea5572bb7bbdf19e616f3550fccd9d&auto=format&fit=crop&w=500&q=60',
fit: BoxFit.cover,
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
),
listOfWidget(),
],
),
However error says
The element type 'List' can't be assigned to the list type 'Widget'.
I totally understand what's going on but I don't know how to fix this. How can I refactor this?