0

I want to display an image represented by the link https://www.authenticatorApi.com/pair.aspx?AppName=MyApp&AppInfo=John&SecretCode=12345678BXYT with CachedNetworkImage but get this Failed to decode image error. However clicking the link directly will show you the qrcode image.
Please what can I do?

3
  • 1
    This link is not an image, it's an html with an image inside, so use webview or flutter_html to display it in a container. Commented Sep 25, 2022 at 2:18
  • make this an answer so i can accept it Commented Oct 10, 2022 at 16:32
  • Answer entered. Commented Oct 10, 2022 at 18:57

2 Answers 2

1

That's not an image link, use an image that end with image extension like .png or .jpeg or .jpg or any other image format

some link like this

https://www.w3schools.com/html/pic_trulli.jpg
Sign up to request clarification or add additional context in comments.

Comments

0

This link is not an image, it's an html with an image inside, so use webview or flutter_html to display it in a container.

webview_flutter

class WebViewExample extends StatefulWidget {
  const WebViewExample({Key? key}) : super(key: key);

  @override
  State<WebViewExample> createState() => WebViewExampleState();
}

class WebViewExampleState extends State<WebViewExample> {
  @override
  void initState() {
    super.initState();
    // Enable virtual display.
    if (Platform.isAndroid) WebView.platform = AndroidWebView();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar:  AppBar(title:const Text('WebView'),),
      body: const WebView(
        initialUrl:
            'https://www.authenticatorapi.com/pair.aspx?AppName=MyApp&AppInfo=John&SecretCode=12345678BXYT',
      ),
    );
  }
}

Flutter_html

import 'package:flutter_html/flutter_html.dart';
class FlutterHtmlExample extends StatefulWidget {
  const FlutterHtmlExample({Key? key}) : super(key: key);

  @override
  State<FlutterHtmlExample> createState() => FlutterHtmlExampleState();
}

class FlutterHtmlExampleState extends State<FlutterHtmlExample> {

  @override
  void initState() {
    super.initState();
  }
  final htmlData = r'''<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<iframe src="https://www.authenticatorApi.com/pair.aspx?AppName=MyApp&AppInfo=John&SecretCode=12345678BXYT" title="W3Schools Free Online Web Tutorials"></iframe>
</body>
</html>''';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar:  AppBar(title:const Text('WebView'),),
      body: SingleChildScrollView(
        child: Html(
          data: htmlData,
        ),
      )
    );
  }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.