CoinGeckoApi not responding in flutter

29 views Asked by At

It used to work and the image of the coin was displayed, but for several days this error is displayed instead of the image of the coins. error

enter image description here

 FutureBuilder(
                                                    future:
                                                        getCoinDataDogeCoin(),
                                                    builder: (context,
                                                        AsyncSnapshot<
                                                                CoinGeckoResult<
                                                                    prefix
                                                                        .Coin?>>
                                                            snapshot) {
                                                      return (snapshot
                                                              .hasData)
                                                          ? Center(
                                                              child: Image
                                                                  .network(
                                                                      "${snapshot.data!.data!.image!.small}"),
                                                            )
                                                          : CircularProgressIndicator();
                                                    }),

enter image description here

1

There are 1 answers

0
Md. Yeasin Sheikh On

As error , it is getting null data and you are using !. Try checking if the value is null or not

if(snapshot.data?.data?.image?.small !=null) Image(....

Here we are accepting null with ? and using ! after checking not null.