getOEmbedData method

Future<OEmbedData?> getOEmbedData(
  1. Uri url
)

Retrieves OEmbed data for a given URL.

Makes an HTTP GET request to the specified URL and returns the OEmbed data if the request is successful (status code 200). Otherwise, returns null.

The url parameter specifies the URL for which to retrieve the OEmbed data. It should be a valid Uri object.

Example usage:

Uri url = Uri.parse('https://example.com');
OEmbedData? data = await getOEmbedData(url);

Implementation

Future<OEmbedData?> getOEmbedData(Uri url) async {
  final res = await http.get(Uri.https(this.url.authority, this.url.path, {'url': url.toString(), ...this.url.queryParameters}));
  if (res.statusCode == 200) {
    var item = OEmbedData.fromJson(jsonDecode(res.body));
    return item;
  }
  return null;
}