Giter VIP home page Giter VIP logo

any_link_preview's Introduction

visitor badge Twitter Badge LinkedIn Badge
BuyMeACoffee PayPal

Hey there πŸ‘‹

I’m Suresh, a senior full-stack engineer, creative coder, an entrepreneur and self-proclaimed film script writer. I make it my mission to translate user-focused designs into pixel-perfect websites or applications that run blazing fast. I am also into blockchain development & crypto's.

Want to know more about me? Check out my portfolio.


Want to know more about my company? Check out my product


πŸ“ Latest Blog Posts



πŸ“Œ Pinned Repositories





πŸ“Š GitHub Stats:




πŸ’Ό Skills

Dart Flutter React Native React NodeJS Express.js TypeScript Solidity Firebase MongoDB Google Cloud DigitalOcean Azure Adobe XD Ant-Design Jira

More Skills

CSS3 HTML5 Java JavaScript Markdown Shell Script Cloudflare Vercel Apollo-GraphQL NPM JWT React Router Socket.io Redux Nginx Realm Redis SQLite Postgres Sketch Figma Adobe After Effects Adobe Illustrator Swagger Postman Gradle ESLint Jira Notion Trello Heroku AWS Ant-Design Bootstrap Chakra FastAPI Fastify Spring ElasticSearch Docker Raspberry Pi


any_link_preview's People

Contributors

clementpeter avatar cybertheory avatar f-mehues avatar ghpranav avatar keiwanmosaddegh avatar legoffmael avatar mlars84 avatar omaryehiadev avatar salim97 avatar sur950 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

any_link_preview's Issues

Feature Request: onError callback

I think a decent amount of my personal friction with using the library could be removed if the onus of error handling was moved onto the consuming developer from the library itself.

  • I'm seeing error logging in my monitoring tool from the NetworkImage not being able to load content, which is giving me false positives
  • I want to be able to choose exactly how my error is presented using language of the error itself
  • I want to be able to determine what I actually consider is a true error based on the content of the error

Proposed change:

  • AnyLinkPreview has a property that is: Widget Function(Context, Metadata, Error) onError; , that returns a widget to be displayed in the event of a caught exception.
    -- Personally, I think this would trump the need for errorImage, errorBody, errorTitle, and errorWidget, but I recognize that backwards compatibility wins.

SetState not changing the preview, is this even possible?

Thank you for the plugin!

Could you possibly let me know if it's possible to change the url in setstate?

When I try to do this absolutely nothing happens when url is changed and setstate launched.

What I got as an example:

  String previewUrl = 'https://google.com';


Widget build(BuildContext context) {
 

    PostsViewModel viewModel = Provider.of<PostsViewModel>(context);
    return WillPopScope(
      onWillPop: () async {
        await viewModel.resetPost();
        return true;
      },
      child: ModalProgressHUD(
        progressIndicator: circularProgress(context),
        inAsyncCall: viewModel.loading,
        child: Scaffold(
          key: viewModel.scaffoldKey,
          appBar: AppBar(
            leading: IconButton(
              icon: Icon(Feather.x),
              onPressed: () {
                viewModel.resetPost();
                Navigator.pop(context);
              },
            ),
            title: Text('MyApp'),
            centerTitle: true,
            actions: [
              InkWell(
                onTap: () async {
                  print(controller.text);
                  await postToApi(viewModel.description);
                  controller.clear();
                  viewModel.resetPost();

                  Navigator.pushReplacement(
                    context,
                    MaterialPageRoute(builder: (context) => TabScreen()),
                  );
                },
                child: Padding(
                  padding: const EdgeInsets.all(20.0),
                  child: Text(
                    'Post'.toUpperCase(),
                    style: TextStyle(
                      fontWeight: FontWeight.bold,
                      fontSize: 15.0,
                      color: Theme.of(context).accentColor,
                    ),
                  ),
                ),
              )
            ],
          ),
          body: ListView(
            children: [

              AnyLinkPreview(
                link: previewUrl,
                displayDirection: UIDirection.UIDirectionHorizontal,
                cache: Duration(hours: 1),
                backgroundColor: Colors.grey[300],
                errorWidget: Container(
                  color: Colors.grey[300],
                  child: Container(),
                ),
              ),
Padding(
                padding: EdgeInsets.all(10),
                child: Column(children: [
                  Container(
                    width: double.infinity,
                    child: Text(
                      'Link'.toUpperCase(),
                      style: TextStyle(
                        fontSize: 15.0,
                        fontWeight: FontWeight.w600,
                      ),
                    ),
                  ),
                  TextFormField(
                    decoration: InputDecoration(
                      hintText: 'Source',
                      focusedBorder: UnderlineInputBorder(),
                    ),
                    maxLines: null,
                    onChanged: (value) {
                      _url1 = value;
                      previewUrl = value;

                    },
                  ),
                  TextButton(
                    child: Text("Fetch"),
                    onPressed:() {
                      setState(() {
                        print(previewUrl);
                      });
                    },
                  )
                ]),
              ),
]);

However this does not refresh the preview even though previewURL changes with setState. Any way to achieve this?

Running the latest RC as version.

Doesn't work for this url (base64 image)

This is the url I tested: http://www.phoenicia.it/

I don't know if this is a problem of how the webpage is coded, but link_view_vertical.dart tries always to use NetworkImage, but in this case the imageUri parameter is not an uri, but a data:image in base64 format as String.

I added a momentary fix. Instad of

image: DecorationImage(image: NetworkImage(imageUri), fit: BoxFit.cover)

I changed it to:
image: DecorationImage(image: img, fit: BoxFit.fitWidth,)

where img definition is this:

ImageProvider img = NetworkImage(imageUri);
if(imageUri.startsWith('data:image')){
   img = MemoryImage(base64Decode(imageUri.substring(imageUri.indexOf('base64') + 7)));
}

Hope it helps.

Added screenshot of the code
immagine

wrong urls

for dynamic urls. how are wrong urls handled? because wrong links seems to break the app. I tried this link htps://asd.com and its raising at io_client.dart and also osError: OSError (OS Error: connection refused, errno = 111). pls is there a bull to check if a url is valid or not?

Version failing with Flutter 2

Hi,

I get a "version solving failed" error after upgrading to Flutter 2.0.1.

Please could you update the package versions so that they are compatible with Flutter v2.

Thanks

Preview and getMetadata function aren't working with TikTok URL

I'm trying to open a TikTok preview but it doesn't work.

AnyLinkPreview(
       link: "https://tiktok.com/@andcarli/video/7165212193921715462?is_from_webapp=1&sender_device=mobile&sender_web_id=7187368554588751365",
)

The method getMetadata doesn't work too.
Screenshot 2023-01-11 at 10 49 21

Error in CacheManager.getJson(String key)

See code at line #8 and #9:
dynamic cache = sharedPreferences.getString(key); var jsonMapCache = jsonDecode(cache) as Map<dynamic, dynamic>;
Line #8, dynamic cache = sharedPreferences.getString(key);, sometimes returns null, which cause error at line 9 when it tries to jsonDecode an empty String. Please add null check around line #9.

type 'double' is not a subtype of type 'BorderRadiusGeometry?'

when i try to change border radius , its showing error type 'double' is not a subtype of type 'BorderRadiusGeometry?'

the goal is i want to make borderRadius 0

this my code

   AnyLinkPreview(
                                  link: metadata,
                                  titleStyle: TextStyle(fontSize: 14, color: Colors.black, fontWeight: FontWeight.w400),
                                  bodyStyle: TextStyle(fontSize: 12, color: Colors.black.withOpacity(0.5)),
                                  borderRadius: 0,
                                  displayDirection: UIDirection.UIDirectionHorizontal,
                                  cache: Duration(hours: 1),
                                  bodyMaxLines: 3,
                                  boxShadow: [BoxShadow(color: kChacaYellowColor)],
                                  backgroundColor: kChacaYellowColor,
                                  errorWidget: Container(
                                    color: Colors.grey[300],
                                    child: Text('Oops!'),
                                  ),
                                  errorImage:
                                      'http://4.bp.blogspot.com/-GZEA28juPQ4/Urrv36Bp-4I/AAAAAAAAAOk/InvzgxJCr3s/s1600/error.png',
                                ),

thanks~

Error while using www. in the twitter url

When i use the url "https://www.twitter.com" it is showing error.
But when I am using url "https://twitter.com" (without www.) it is not showing error and I am able to see the link preview.

Here's the error :
D/InsetsController(11360): show(ime(), fromIme=true)
I/flutter (11360): Error while retrieving cache data => type 'Null' is not a subtype of type 'String'
D/InputMethodManager(11360): showSoftInput() view=io.flutter.embedding.android.FlutterView{bfbbd4d VFE...... .F...... 0,0-1080,2154 #2 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT

Update library

Please update http library to latest version 1.1.0 actually

This will solve incompatibility issues with others libraries

Because aggregator_news depends on any_link_preview ^3.0.1 which depends on http ^1.0.0, http ^1.0.0 is required.
So, because aggregator_news depends on http ^0.13.6, version solving failed.

Widget borders

Hello, I want to remove the widget borders (rounded, color, padding... so no borders at all). Is there anything to achieve this?

Everything else is good.

cant launch link

  • any_link_preview: ^1.0.6

Cant Launch Link

E/flutter (14536): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Could not launch https://www.recruitinghub.com/
E/flutter (14536): #0      _AnyLinkPreviewState._launchURL (package:any_link_preview/any_link_preview.dart:147:7)
E/flutter (14536): <asynchronous suspension>

Preview function aren't working with ZOZOTOWN URL

I'm trying to open a ZOZOTOWN preview but it doesn't work.

My code

AnyLinkPreview(
       link: "https://zozo.jp/shop/futierlandandsasa/goods-sale/46114752/?did=75805438&rid=1093",
)

I can view the preview correctly on other sites, but this link does not show the preview.
Please advise!

FormatException (FormatException: Unexpected extension byte (at offset 9504)) for certain valid urls

I keep hitting this FormatException from convert_patch.dart when https://www.google.com/ is the passed as the link. Code example:

AnyLinkPreview(
  link: "https://www.google.com",
  cache: Duration(hours: 1),
  backgroundColor: Colors.grey[300],
  errorWidget: Container(
    color: Colors.grey[300],
    child: Text('Oops!'),
  ),
);

https://www.google.com/ is an unlikely use case and not particularly concerning, but it is concerning that AnyLinkPreview is getting stuck in a loading state rather than handling this more gracefully. I am on Flutter 2.2.2 and using any_link_preview ^2.0.0-rc.

If I run the example from the repo I am also getting Web page resolution failure from:https://www.google.com Error:FormatException: Bad GBK encoding 0xd00c. I'm assuming this is due to how the document body is being parsed and google being an outlier, but is there concern that this could be a common issue with url's?

Multimedia doesn't open

I am trying to open the multimedia link which has a link, while it shows the link data correctly but it doesn't load the image.

 SizedBox(
                        height: 400,
                        child: AnyLinkPreview(
                          link:
                              "https://www.amazon.com/gp/product/B00JZEW4XS?ie=UTF8&th=1&linkCode=li1&tag=pratiksharu-20&linkId=1d34bc8b2b8b01132376486955c5d313&language=en_US&ref_=as_li_ss_il",
                          displayDirection: UIDirection.uiDirectionVertical,
                          cache: Duration(hours: 1),
                          backgroundColor: Colors.grey[300],
                          showMultimedia: true,
                          errorWidget: Container(
                            color: Colors.grey[300],
                            child: Text('Oops!'),
                          ),
                          errorImage:
                              "https://i.ytimg.com/vi/z8wrRRR7_qU/maxresdefault.jpg",
                        ),
                      ),

Can't get domain name of websites

Add the option to get domain name of the website url in metadata. Instead of displaying the full url just show the domain.
Issue

This is the expected domain sample
expected

Why am I getting some weird images, weird titles and weird body text from links?

I want to get image, title and body from link. However, I'm getting some weird images, weird titles and weird body text from the link.

Here is the strange result:

Strange result

My link:

https://www.bloomberg.com/news/articles/2022-11-15/russia-expected-to-agree-to-extend-black-sea-grain-export-deal

My code:

AnyLinkPreview(
  link: "https://www.bloomberg.com/news/articles/2022-11-15/russia-expected-to-agree-to-extend-black-sea-grain-export-deal",
),

Feel free to leave a comment if you need more information.

Why am I getting some weird images, weird titles and weird body text from links? I would appreciate any help. Thank you in advance!

[Help] Get Site Name

Some time in metadata have a property og:site_name . I want to get that if it exist. Any idea to solve this problem

Link preview does not change when providing link via text controller.

I am pasting link in TextField and using setState to update the state but the link preview of url does not appear/update. It shows error widget.

code

`class VerifyLinkUI extends StatefulWidget {
@OverRide
_VerifyLinkUIState createState() => _VerifyLinkUIState();
}

class _VerifyLinkUIState extends State {
TextEditingController linkUrlController = TextEditingController();

@OverRide
Widget build(BuildContext context) {
return Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
controller: linkUrlController,
decoration: const InputDecoration(
hintText: "Paste link of google drive,google docs,youtube etc",
hintStyle: TextStyle(fontSize: 12)),
onChanged: (value) {
setState(() {
logger.d(
'linkUrlController is ============= ${linkUrlController.text}');
});
},
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: AnyLinkPreview(
link: linkUrlController.text,
displayDirection: UIDirection.UIDirectionHorizontal,
showMultimedia: true,
bodyMaxLines: 5,
bodyTextOverflow: TextOverflow.ellipsis,
titleStyle: const TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 15,
),
bodyStyle: const TextStyle(color: Colors.grey, fontSize: 12),
errorBody: 'Show my custom error body',
errorTitle: 'Show my custom error title',
errorWidget: Container(
color: Colors.grey[300],
child: const Text('Oops!'),
),
errorImage: "https://google.com/",
cache: const Duration(days: 7),
backgroundColor: Colors.grey[300],
borderRadius: 0,
removeElevation: false,
boxShadow: const [BoxShadow(blurRadius: 3, color: Colors.grey)],
onTap: () {}, // This disables tap event
),
),
],
);
}
}
`

Null safety version

Hello,

Do you have any plans to migrate this package to support null safety?

Thanks!

A bug in any_link_preview package

I found a bug in the any_link_preview package.
I asked a question and got answer in Stack Overflow.
This and this comment are about the bug:
https://stackoverflow.com/questions/74471700/how-to-make-a-chat-bubble-like-whatsapps-chat-bubble-in-flutter#comment131464378_74471788
https://stackoverflow.com/questions/74471700/how-to-make-a-chat-bubble-like-whatsapps-chat-bubble-in-flutter#comment131464458_74471788

Ok, I added placeholders. Only, if something like the 2nd and 4th image appears in my question, which contains words that are not URLs, no results are returned

There seems to be a problem with the package. I have no idea what's next.

Second and fourth pictures:

Second picture

Forth picture

I really hope this bug can be fixed. If this bug is fixed, this package will really be 100% usable in chat. Thanks in advance!

Twitter Links Not Loading with AnyLinkPreview.getMetadata

final url = await reader.readValue(Formats.uri);

Metadata? metadata = url == null
                ? null
                : await AnyLinkPreview.getMetadata(link: url.uri.toString());

flutter: AnyLinkPreview - Error in https://twitter.com/stats_feed/status/1705225138495513032?s=20 response (ClientException: Redirect loop detected, uri=/stats_feed/status/1705225138495513032?s=20)

is always returning null for Twitter cards. Is this expected?

other websites works.

Twitter links work with this lib: https://pub.dev/packages/ogp_data_extract
Might it be useful to merge their functionality in?

Twitter Links It shows Enable Javascript ! Do we have option to enable disable javascript?

AnyLinkPreview fail to load Twitter Links.
It is showing error widget only.

AnyLinkPreview( link: "https://www.twitter.com/FlutterDev/status/1435664264816205832", borderRadius: 4, backgroundColor: Colors.white, removeElevation: true, displayDirection: UIDirection.UIDirectionVertical, showMultimedia: true, bodyMaxLines: 3, bodyTextOverflow: TextOverflow.ellipsis, titleStyle:TextStyle(fontSize: 20), bodyStyle: TextStyle(fontSize: 14), ),

Title Something went wrong

Error Body
JavaScript is not available. We’ve detected that JavaScript is disabled in this browser. Please enable JavaScript or switch to a supported browser to continue using twitter.com. You can see a list of supported browsers in our Help Center. Help Center Terms of Service Privacy Policy Cookie Policy Imprint Ads info Β© 2021 Twitter, Inc. Something went wrong, but don’t fret β€” let’s give it another shot.

Adding Screen shot for output reference here
Simulator Screen Shot - iPhone 13 - 2021-10-20 at 02 13 24

Adding headers to the http request

Currently there's no way to add headers to the requests made by the package. I think this feature would be really useful, specially when working with self hosted CORS proxies, since it would allow implementing authentication.

Not able to display a valid link preview.

i am using this link - "https://www.brainyquote.com/topics/motivational-quotes" and it's saying opps! . You can check, it's a valid link. Also i tried displaying google forms preview and it gives error -'show your custom error body.'

*In whatsApp I am able to see the preview though"

googel docs link : "https://forms.gle/tKgJm9A3kLrrje4j6"
Note: "this is short url of google form. original url shows the preview of google forms but not the short url".
code snippet used:

AnyLinkPreview(
link: "https://forms.gle/tKgJm9A3kLrrje4j6",
// link:"https://www.brainyquote.com/topics/motivational-quotes",
displayDirection: UIDirection.UIDirectionHorizontal,
showMultimedia: true,
bodyMaxLines: 5,
bodyTextOverflow: TextOverflow.ellipsis,
titleStyle: TextStyle(
color: Colors.blue,
fontWeight: FontWeight.bold,
fontSize: 15,
),
bodyStyle: TextStyle(color: Colors.black, fontSize: 12),
errorBody: 'Show my custom error body',
errorTitle: 'Show my custom error title',
errorWidget: Container(
color: Colors.grey[300],
child: Text('Oops'),
),
errorImage: "https://google.com/",
cache: Duration(days: 7),
backgroundColor: Colors.blue[50],
borderRadius: 12,
removeElevation: true,
// boxShadow: [BoxShadow(blurRadius: 3, color: Colors.grey)],
),

Google News link return Google News icon instead of article image

Error on most url preview in web configuration

So, url preview work great on iOS and Android, but, when I start my app in chrome, I've got this error on most link

Error while retrieving cache data => Invalid argument: null

Error is easily reproduced with the sample provided in pub.dev

Is there a way to get rid of Error on NetworkImageLoadException for a HTTP request failed statusCode: 404?

This is the error I get in my debug console when loading the link:
'
HTTP request failed, statusCode: 404, https://www.lapatilla.com/wp-content/uploads/2015/07/C_jXKuyXoAAXIWi-696x392.jpg?fit=696%2C392
'
It seems like its an issue with NetworkImage() widget.

I tried handling the error with the provided errorWidget, errorImage etc but it does not show. Or maybe I am using it wrong.

Is there a way to get rid of his error shown in the debug console?

Error while retrieving cache data

I/flutter ( 3666): Error while retrieving cache data => type 'Null' is not a subtype of type 'String'

Often appears this message in debug console

 any_link_preview.Metadata? metadata1 =
              await any_link_preview.AnyLinkPreview.getMetadata(
            link: link,
            cache: const Duration(days: 1),
          );

Doesn't work with multiline JSON field

This URL https://www.cucchiaio.it/ricetta/chili-con-carne/ contains a JSON with multilnes.
I know it's not good to have a multiline JSON, but for my work I need to deal with this particular case.
As for now, in json_ld_parser.dart, the _parseToJson functions calls:

var d = jsonDecode(data);

which make the code crash because of unexpected char.

The fix is easy: I replaced all the newlines with a space character, with:

var d = jsonDecode(data.replaceAll('\n', ' '));

Hope it helps

version solving failed

I am using firebase_storage legacy package which requires http ^0.12.2 and and any_link_preview required http ^0.13.0 and i am getting this error:

Because no versions of firebase_storage match >7.0.0 <8.0.0 and firebase_storage 7.0.0 depends on firebase_storage_web ^0.1.1+3, firebase_storage ^7.0.0 requires firebase_storage_web ^0.1.1+3.

Because firebase_storage_web 0.1.1+3 depends on http ^0.12.2 and no versions of firebase_storage_web match >0.1.1+3 <0.2.0, firebase_storage_web ^0.1.1+3 requires http ^0.12.2.

Thus, firebase_storage ^7.0.0 requires http ^0.12.2.
So, because app1 depends on both firebase_storage ^7.0.0 and http ^0.13.0, version solving failed.
pub get failed (1; So, because awarenett depends on both firebase_storage ^7.0.0 and http ^0.13.0, version solving failed.)
exit code 1

Option To Remove Print Statements

It looks like there's a number of debug logs that show up in the console. Any way we can include a flag property as part of AnyLinkPreview to disable these?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.