Prathamesh Gathadi
Prathamesh Gathadi

Reputation: 11

The following _Exception was thrown resolving an image codec: Exception: Invalid image data

Trying to fetch Tradingview Image but getting this error.
Is their another method to fetch Tradingview Images. \

I want to display TradingView image.

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Image(
              image: NetworkImage(
                'https://www.tradingview.com/x/ag1X9C1z',
                scale: 1,
              ),
            ),
            SizedBox(
              height: 20,
            ),
            Image.network(
              'https://www.tradingview.com/x/ag1X9C1z/',
              scale: 1,
            ),
          ],
        ),
      ),
    );
  }

Error
Invalid Image Data

Upvotes: 1

Views: 4610

Answers (2)

Chris Buckett
Chris Buckett

Reputation: 14398

The problem is that the tradingview URLs you have link to an HTML page that contains the image, rather than the image itself.

Your image link (which is actually HTML): https://www.tradingview.com/x/ag1X9C1z/ contains the actual image: https://s3.tradingview.com/snapshots/a/ag1X9C1z.png

So I think you need to change your URL to https://s3.tradingview.com/snapshots/a/ag1X9C1z.png

Upvotes: 1

keyur
keyur

Reputation: 181

Please check Your url. you can try to other url and check it.

 Image.network(
            'https://picsum.photos/250?image=9',
            scale: 1,
          ),

Upvotes: 1

Related Questions