css_text 0.5.0 copy "css_text: ^0.5.0" to clipboard
css_text: ^0.5.0 copied to clipboard

outdated

Allows you to use simple CSS to style your text

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:css_text/css_text.dart';

void main() {
  runApp(Home());
}

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    String htmlContent = """
<body>
<p style="font-size:1.5em;color:#99ff0011">
Hello <b style="font-style:italic">World</b>!!
<br/>
How are you <span style="font-family:RobotoBlack;color:#ff0000;background:#33eeff00">today?</span>
<br/>
<b>But</b> why are you doing <a href="https://google.com">this?</a><br/>
<br/>
<span style="text-decoration: underline solid; font-size:2em">Can you tell <del>me</del>?</span>
<br/>
Please visit <a style="font-weight:bold;" href="https://docs.flutter.io">Flutter docs</a>
</p>
</body>
""";

    var myRichText = HTML.toRichText(context, htmlContent, linksCallback: (link) {
        // You can now use the url_launcher to open the link in a browser. Or you can handle
        // the link in your app itself. This gives you complete control.
        // For now, let's just print it
        print(link);
    });

    return MaterialApp(
      home: Scaffold(
      appBar: AppBar(title: Text("Demo")),
      body: Container(padding:EdgeInsets.all(16.0), child:myRichText)
    ));
  }
}
27
likes
0
pub points
71%
popularity

Publisher

unverified uploader

Allows you to use simple CSS to style your text

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, xml

More

Packages that depend on css_text