In my markdown return
[![Build & Release](https://github.com/aelayyuu/****/actions/workflows/action.yml/badge.svg)](https://github.com/aelayyuu/****/actions/workflows/action.yml)
Error is
HTTP request failed, statusCode: 404,
https://github.com/aelayyuu/****/actions/workflows/action.yml/badge.svg
When the exception was thrown, this was the stack:
#0 NetworkImage._loadAsync (package:flutter/src/painting/_network_image_io.dart:97:9)
<asynchronous suspension>
Image provider:
NetworkImage("https://github.com/aelayyuu/****/actions/workflows/action.yml/badge.svg",
scale: 1.0)
Image key:
NetworkImage("https://github.com/aelayyuu/****/actions/workflows/action.yml/badge.svg",
scale: 1.0)
My code is using markdown: ^5.0.0, flutter_svg: ^1.1.1 1 and flutter_markdown: ^0.6.10 2
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:markdown/markdown.dart' as md;
Markdown(
controller: controller,
selectable: true,
data: aboutMD,
// imageBuilder: imageBuilder(aboutMD),
extensionSet: md.ExtensionSet(
md.ExtensionSet.gitHubFlavored.blockSyntaxes,
[
md.EmojiSyntax(),
...md.ExtensionSet.gitHubFlavored.inlineSyntaxes,
md.ImageSyntax(),...md.ExtensionSet.gitHubFlavored.inlineSyntaxes
],
),
)
How to show image such as svg, png, jpg in flutter markdown?
CodePudding user response:
Solved:
Url lunch
Future<void> _onTapLink(String text, String? href, String title) async {
if (href == null) return;
final Uri url = Uri.parse(href);
if (!await launchUrl(
url,
mode: LaunchMode.externalApplication,
)) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Wrong address: $href'),
),
);
}
}
Image showing
import 'package:markdown/markdown.dart' as md;
Markdown(
selectable: true,
data: data,
onTapLink: onTapLink,
extensionSet: md.ExtensionSet(
/*blockSyntaxes=*/ md.ExtensionSet.gitHubFlavored.blockSyntaxes,
/*inlineSyntaxes=*/ md.ExtensionSet.gitHubFlavored.inlineSyntaxes,
),
);