This is my Data:
Activity(
name: ‘Times Square’,
continentType: ContinentType.northAmerica,
description:
‘A vibrant intersection and tourist destination in New York City.’,
location: const PlaceLocation(
latitude: 40.758896,
longitude: -73.985130,
street: ‘Broadway’,
city: ‘New York City’,
country: ‘USA’),
),
I want to get the image with this:
Future fetchImage(String activityName) async {
final formattedName = activityName.replaceAll(‘ ‘, ‘_’);
final formattedLink =
‘http://en.wikipedia.org/w/api.php?action=query&titles=$formattedName&prop=pageimages&format=json&pithumbsize=1000’;
final response = await http.get(Uri.parse(formattedLink));
final Map<String, dynamic> data =
json.decode(response.body) as Map<String, dynamic>;
final pages = data['query']['pages'];
final pageId = pages.keys.first;
final imageUrl = pages[pageId]['thumbnail']['source'] as String;
return imageUrl;
}
I dont´t even get to the map code.
Some help?
I tried this implementation.
DeveloperDawid is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.