...
'''; class GuardianExample extends StatelessWidget { const GuardianExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) {// If you still want MarkdownWidget:
// final markdown = htmlToMarkdown(html);
return Scaffold(
appBar: AppBar(title: const Text('Guardian Golem')),
body: SingleChildScrollView(
padding: const EdgeInsets.all(12),
child: Html(
data: html,
onLinkTap: (url, _, __) async {
if (url != null) {
final uri = Uri.parse(url);
if (await canLaunchUrl(uri)) {
await launchUrl(uri);
}
}
},
),
),
);
}
}
void main() {
runApp(const MaterialApp(
home: GuardianExample(),
debugShowCheckedModeBanner: false,
));
}
---
4️⃣ Bonus: Why You Might Prefer flutter_markdown
markdown_widget is a thin wrapper around the older markdown package and is not actively maintained.
If you need more features (tables, task lists, footnotes, etc.) consider using fluttermarkdown:
dart
import 'package:fluttermarkdown/fluttermarkdown.dart';
Markdown(
data: markdownString,
onTapLink: (text, url, ) async { / open url / },
)
It’s well‑supported and offers a MarkdownStyleSheet for styling.
---
Bottom Line
| Want to show Markdown? | KeepMarkdownWidget & feed it Markdown. |
|------------------------|-------------------------------------------|
| Want to show HTML? | Use flutter_html or a WebView instead. |
Feel free to drop the markdown string you’d like to render, and I can help you tweak the styling or add custom widgets for tables, lists, etc.
No comments yet. Be the first to comment!