type 'Container' is not a subtype of type 'List<Widget>'

738 views
Skip to first unread message

sanjeev baria

unread,
May 16, 2020, 7:33:02 AM5/16/20
to Flutter Development (flutter-dev)
 return ListView.builder(
                            //  itemCount: snapshot.data.length,
                              itemBuilder: (_,i) => Row(
                                    mainAxisAlignment:
                                        MainAxisAlignment.spaceEvenly,
                                    children: index < snapshot.data.length-1
                                        ? <Widget>[
                                            Column(
                                              children: <Widget>[
                                                geetBookCard(
                                                    "assets/picfour.jpeg",
                                                    snapshot
                                                        .data[(index % 2 != 0
                                                                ? index += 1
                                                                : index)
                                                            ]
                                                        .data['Name'],
                                                    snapshot.data[index]
                                                        .data['Price'],
                                                    true,
                                                    context),
                                                SizedBox(height: 15.0)
                                              ],
                                            ),
                                            Column(
                                              children: <Widget>[
                                                geetBookCard(
                                                    "assets/picfour.jpeg",
                                                    snapshot
                                                        .data[ (index % 2 == 0
                                                                ? index += 1
                                                                : index)
                                                            ]
                                                        .data['Name'],
                                                    snapshot.data[index]
                                                        .data['Price'],
                                                    true,
                                                    context),
                                              ],
                                            ),
                                          ]
                                        : blank(i),
                                  ));
 Widget blank(int i){
    return Container(
      width: 0,
      height: 0,
    );
  }

please help me I want to divide data from firebase into two columns i divided it but getting type 'Container' is not a subtype of type 'List<Widget>' that error please give me a suggestion.




home.dart

Souvik Dutta

unread,
May 16, 2020, 7:36:37 AM5/16/20
to sanjeev baria, Flutter Development (flutter-dev)
Surround container in return statement with brackets return [ Container ];

Souvik flutter dev

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/318d01f8-2c9f-45be-82a9-0a12794765c0%40googlegroups.com.

sanjeev baria

unread,
May 16, 2020, 7:43:30 AM5/16/20
to Flutter Development (flutter-dev)
how can i solve this error?

Suzuki Tomohiro

unread,
May 16, 2020, 7:47:25 AM5/16/20
to Flutter Development (flutter-dev)
Hi Sanjeev,

Did you read Souvik’s email?

On Sat, May 16, 2020 at 07:43 sanjeev baria <sanjeev...@gmail.com> wrote:
how can i solve this error?

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.

Souvik Dutta

unread,
May 16, 2020, 8:46:26 AM5/16/20
to sanjeev baria, Flutter Development (flutter-dev)
I just said how to solve it. Replace return Container(); with return [ Container(), ];
This has to solve you issue...

Souvik flutter dev
Reply all
Reply to author
Forward
0 new messages