I have tried for the past days to retrieve datas from this API (https://www.bkgchallenge.it/badmin/APIM/getsponsor.php) and loop it into a carousel (I would need to show only the name and get the URL for the image).
import 'package:equatable/equatable.dart';
import 'package:http/http.dart' as http;
import 'package:test_v02/models/models.dart';
class RemoteService {
Future<List<Sponsor>?> getSponsor() async {
var client = http.Client();
var uri =
Uri.parse('https://www.bkgchallenge.it/badmin/APIM/getsponsor.php');
var response = await client.get(uri);
if (response.statusCode == 200) {
var json = response.body;
return sponsorFromJson(json);
}
}
}
class Category extends Equatable {
final String imageUrl;
final String name;
const Category({
required this.imageUrl,
required this.name
});
@override
List<Object?> get props => [imageUrl];
static List<Category> categories = [
const Category(
imageUrl:
'https://upload.wikimedia.org/wikipedia/commons/9/9a/Gull_portrait_ca_usa.jpg',
name: 'Seagull',
),
const Category(
imageUrl:
'https://upload.wikimedia.org/wikipedia/commons/9/9a/Gull_portrait_ca_usa.jpg',
name: 'Seagull',
)
];
}
This is the solution I tried to come up with, this page sends the link and the name to the page with the carousel, I don't know however how to extract the URL and the name and insert them into
const Category(
imageUrl:
'https://upload.wikimedia.org/wikipedia/commons/9/9a/Gull_portrait_ca_usa.jpg',
name: 'Seagull',
)