flutter_link_previewer icon indicating copy to clipboard operation
flutter_link_previewer copied to clipboard

Can not fetch image of some link like ChatGPT or TikTok

Open harrynguyen2510 opened this issue 1 year ago • 1 comments

There's some issue that the data from LinkPreview can not fetch image from link like ChatGPT or TikTok, but works well some common link like Google, YouTube, Drive, StackOverFlow, etc

LinkPreview(
              enableAnimation: true,
              onPreviewDataFetched: (data) => setPreviewDataURL(data),
              previewData: previewURLdata, // Pass the preview data from the state
              text: urlString,
              width: widget.width,
              previewBuilder: (p0, p1) {
                return Column(
                  children: [
                    // IMAGE
                    if (p1.image != null)
                      Container(
                          height: 100,
                          width: widget.width + 4,
                          margin: const EdgeInsets.fromLTRB(1, 1, 1, 10),
                          child: ClipRRect(
                            borderRadius: const BorderRadius.only(
                              topLeft: Radius.circular(15),
                              topRight: Radius.circular(15),
                            ),
                            child: Image.network(p1.image!.url, fit: BoxFit.cover),
                          )),

                    // TITLE
                    if (p1.title != null)
                      Container(
                          margin: const EdgeInsets.only(left: 10, right: 10, top: 5),
                          child: Text(p1.title!,
                              maxLines: 3, style: TextStyle(fontWeight: FontWeight.w600, color: widget.titleColor))),

                    // URL
                    if (p1.link != null)
                      Container(
                        margin: const EdgeInsets.only(left: 10, right: 10, bottom: 8),
                        child: Text(
                          p1.link!,
                          overflow: TextOverflow.ellipsis,
                          maxLines: 1,
                          style: TextStyle(
                            color: widget.urlColor,
                          ),
                        ),
                      )
                  ],
                );
              }),```

harrynguyen2510 avatar Jan 22 '24 09:01 harrynguyen2510

Yeah it won't work for everything, sometimes frontend is blocked from reading link metadata. If you want a robust solution that will work for everything, you need a backend solution, something like https://www.linkpreview.net or similar

demchenkoalex avatar Jan 22 '24 12:01 demchenkoalex