0
Follow
0
View

Future builder returns null although my list is not empty

cuitghp 注册会员
2023-01-24 21:45

There's a couple of things to unpack here.

  1. Instead of a ChangeNotifierProvider, I believe you should use a Consumer widget that listens to your Movies provided service when you call the notifyListeners call, so make it Consumer.

  2. You can still call it using the Provider.of above for the sake of making the async call via the FutureBuilder, but I believe because you're not returning anything out of the getTrendingMovies and is just a Future and you're querying the snapshot.hasData, well there is no data coming through the snapshot. Maybe instead you should call snapshot.connectionState == ConnectionState.done as opposed to querying for whether it has data.

  3. Make sure that the response.body is truly returning a JSON value, but I believe your issue is in one of the points above.

About the Author

Question Info

Publish Time
2023-01-24 21:45
Update Time
2023-01-24 21:45