Guest User

Untitled

a guest
Feb 17th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. Future<List> _getColors() async {
  2. Color gradientOne, gradientTwo;
  3. String imageUrl = json['image'];
  4.  
  5. paletteGenerator = await PaletteGenerator.fromImageProvider(
  6. CachedNetworkImageProvider(imageUrl));
  7.  
  8. gradientOne = paletteGenerator.colors.toList()[0];
  9. gradientTwo = paletteGenerator.colors.toList()[1];
  10.  
  11. return [gradientOne, gradientTwo];
  12. }
  13.  
  14. post.gradientColors
  15. .then((result) => {
  16. gradient = result,
  17. this.setState(() {
  18. loading = false;
  19. })
  20. })
  21.  
  22. List<Future> futures = [];
  23.  
  24. for (var post in tmpList) {
  25. futures.add(post.gradientColors);
  26. }
  27. await Future.wait(futures)
  28. .then((result) => {list.addAll(tmpList)});
  29. }
Add Comment
Please, Sign In to add comment