simple_rich_text 2.0.49 copy "simple_rich_text: ^2.0.49" to clipboard
simple_rich_text: ^2.0.49 copied to clipboard

Display a Dart string in Flutter using simple rich text characters.

example/lib/main.dart

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

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(new MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
//    String text = null;
//    String text = 'no format characters';
//    String text = r'format characters: \*\/\_';
//    String text = '_entire string_';
//    String text = '*/_fully loaded!_*/';
//    String text = 'first *bold*.';
//    String text = r'test*\_quoted\_*.';
//    String text = r'don't*close';
//    String text = r'_start at beginning and do not close';
//    String text = r'/Alissa/ is /awesome/!';
//    String text = r'_back__to back_';
//    String text = r'go to _{route}home_ page';
    //String text = '*_/this is all three*_/ (*{color:red}bold*, _underlined_, and /{color:brown}italicized/). _{push:home;color:blue}clickable hyperlink to home screen_';
    //String text = r'This is a text with \nnew line';
    String text =
        r'Now you can change the ~{fontSize:32}size~ of the text. \nInsert a new line.\nChange the ~{backgroundColor:yellow}background color~\nAnd modify more style as: fontFamily, _{decorationColor:blue}decorationColor_, ~{height:3}height~, etc\n\nToo you can open url: _{http:www.google.com;color:blue}go to Google_\nFinaly, you can define textAlign, maxLines and textOverflow';
    return new MaterialApp(
      //set global text scale factor in builder
      builder: (BuildContext context, Widget child) {
        final MediaQueryData data = MediaQuery.of(context);
        return MediaQuery(
          data: data.copyWith(textScaleFactor: 3),
          child: child,
        );
      },

      home: Scaffold(
        // , chars: r"[*]"
//          backgroundColor: Colors.grey[300],
        body: Center(
          child: SimpleRichText(text,
              logIt: false,
              maxLines: 20,
              pre:
                  TextSpan(text: 'PRE', style: TextStyle(color: Colors.purple)),
              post: TextSpan(
                  text: 'POST', style: TextStyle(color: Colors.purple)),
              style: TextStyle(color: Colors.orange),
              textAlign: TextAlign.center,
              textOverflow: TextOverflow.ellipsis,
              textScaleFactor: 1.5),
        ),
      ),
    );
  }
}
84
likes
130
pub points
92%
popularity

Publisher

verified publisheronlyup.com

Display a Dart string in Flutter using simple rich text characters.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, url_launcher

More

Packages that depend on simple_rich_text