getProviders static method
- bool updateProviders = true
Retrieves a list of oEmbed providers from the oEmbed website.
Implementation
static Future<OEmbedProviders> getProviders([bool updateProviders = true]) async {
if (updateProviders || OEmbed.providers.isEmpty) {
final response = await http.get(Uri.parse('https://oembed.com/providers.json'));
if (response.statusCode == 200) {
final List<OEmbed> providers = [
for (dynamic x in json.decode(response.body))
if (x != null) OEmbed.fromJson(x)
];
if (providers.isNotEmpty) {
OEmbed.providers.clear();
OEmbed.providers.addAll(providers);
}
}
}
return OEmbed.providers;
}