Exception: type 'String' is not a subtype of type 'int' of 'index'

Viewed 39

It's my error. How should I solve the typing problem? I used ListView.builder and FutureBuilder at the same time, but I think Json's typing class has a problem


 FutureBuilder<product>(
                      future: futureproduct,
                      builder: (context, snapshot){
                        if (snapshot.hasData) {
                          superheros_length = snapshot!.data;
                           ListView.builder(
                            itemCount: superheros_length.length,
                            itemBuilder: (context, index) {
                              return Container(
                                child: Column(
                                  mainAxisAlignment: MainAxisAlignment.center,
                                  children: [
                                    Row(
                                      mainAxisAlignment:
                                          MainAxisAlignment.spaceAround,
                                      children:
                                            Text(superheros_length.body[index].name),
                        
1 Answers

Please refer to below code

superheros_length = int.parse(snapshot!.data.body);

Related