flyerhq / flutter_link_previewer

Customizable link and URL preview extracted from the provided text with the ability to render from the cache. Ideal for chat applications.
MIT License
72 stars 75 forks source link

Can not fetch image of some link like ChatGPT or TikTok #58

Open harrynguyen2510 opened 7 months ago

harrynguyen2510 commented 7 months ago

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,
                          ),
                        ),
                      )
                  ],
                );
              }),```
demchenkoalex commented 7 months ago

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