flutter 中丰富的链接预览

Shy*_*hil 5 dart flutter flutter-dependencies

是否可以从 url 进行预览,获取所有信息,例如标题、相关文本和图像。有没有我可以轻松使用的插件?

看到这个原生安卓插件

小智 3

你可以这样做:

1)在https://www.linkpreview.net创建用户

2)生成访问密钥。

3)从你的代码调用

 http://api.linkpreview.net/?key=<Your_API_KEY_From_Step_2>&q=https://www.google.com
Run Code Online (Sandbox Code Playgroud)

它返回 JSON 格式的元标记,如下所示:

 {"title":"Google","description":"Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.","image":"http:\/\/www.google.com\/images\/branding\/googlelogo\/1x\/googlelogo_white_background_color_272x92dp.png","url":"https:\/\/www.google.com\/"}
Run Code Online (Sandbox Code Playgroud)

4)在flutter widget中使用它来创建预览。