0

i am creating a wallpaper app in which i am fetching wallpaper through an pexel api. but when i making a variable of response and give it value of http.get(url); and here i am pasting the link of curated wallpaper as given in api but it is giving an error like this : The argument type 'String' can't be assigned to the parameter type 'Uri'. can any one tell me how i can solve. and the tutorial i am following in that he is directly pasting link as a string and it is not giving any error to him. here is sample of that code :

import 'package:http/http.dart' as http;

getTrendingWallpaper() {
    var trendingUrl = "https://api.pexels.com/v1/curated?per_page=1";
    var response = http.get(trendingUrl); // this is giveing this error :  The argument type 'String' can't be assigned to the parameter type 'Uri'
  }
  • Please note that this is **explicitly against the [Pexels API guideline](https://www.pexels.com/api/documentation/#guidelines)**: *"You may not copy or replicate core functionality of Pexels (including making Pexels content available as a wallpaper app)."* – mimocha Mar 12 '22 at 16:56

1 Answers1

0

You should use

var trendingUrl = Uri.parse("https://api.pexels.com/v1/curated?per_page=1");