html_to_flutter 0.0.2+1-pre html_to_flutter: ^0.0.2+1-pre copied to clipboard
A Flutter package to convert HTML to Flutter widgets.
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:html_to_flutter/html_to_flutter.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Simple Html Parser Demo',
theme: ThemeData.dark(),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Html(
config: HtmlConfig(
onAnchorClick: (href) {
log('Opening URL: $href');
// Open the URL in a browser.
},
),
data:
"<p><img alt=\"\" src=\"https://staticassets.zerodha.com/varsity/media/uploads/2023/04/10/v7-cover.jpeg\" style=\"height:338px; width:600px\" /></p><p> </p><p>In the last video, we discussed equity mutual funds. Equities can be thought about as the growth asset class—they are volatile, but they have the highest expected returns. Now, in a portfolio that has a volatile asset class like equity, you need something stable to reduce the volatility as well as diversify. Why? Because having multiple asset classes that rise and fall at the same time makes no sense. This is the role that debt funds play. Debt funds invest in bonds issued by govt and companies when they borrow money. Bonds are less volatile than equities but offer stable and predictable returns. In this video, Karthik explains the basics of debt funds and the key risks.</p><p> </p><p>You can <a href=\"https://www.youtube.com/watch?v=7jLip-C8SQs&list=PLX2SHiKfualGsjgd7fKFC-JXRF6vO73hk&index=7\">watch the video on YouTube here</a>.</p><p> </p><p>To learn more about debt funds, check out <a href=\"https://zerodha.com/varsity/chapter/the-debt-funds-part-1/\">this chapter on Varsity</a>.</p>",
),
),
);
}
}