flutter_text_parser 1.0.0 copy "flutter_text_parser: ^1.0.0" to clipboard
flutter_text_parser: ^1.0.0 copied to clipboard

flutter_text_parser is a Dart library that allows you to parse any string with custom tags and render it as styled spanned text. It supports inline formatting like bold, italic, colors, and more, maki [...]

flutter_text_parser #

flutter_text_parser is a Dart library that allows you to parse strings with custom HTML-like tags and convert them into styled spanned text for Flutter. It supports nested tags, inline formatting, colors, and more.


Features #

  • Parse strings with custom tags like <b>, <i>, <u>, <color:red>, etc.
  • Supports nested tags.
  • Returns a list of TextPart containing NormalText and SpannedText.
  • Easy to convert to styled Flutter widgets.

Installation #

Add this to your pubspec.yaml:

dependencies:
  flutter_text_parser:
    git:
      url: https://github.com/yourusername/flutter_text_parser.git

Then run

flutter pub get

Usage #

import 'package:flutter_text_parser/flutter_text_parser.dart';

void main() {
  String text = "<b><i>Flutter</i></b> is <color:red>awesome</color>!";
  List<TextPart> parsed = text.parsedSpanTexts;

  for (var part in parsed) {
    print(part);
    // Output: SpannedText(text: Flutter, tags: [b, i])
    //         NormalText( is )
    //         SpannedText(text: awesome, tags: [color:red])
  }
}

TextPart Types #

  • NormalText: Regular text without styling.
  • SpannedText: Text with applied tags.
  • SpannedTag: Represents a tag with an optional attribute (like color).

Supported Tags #

  • Bold: or
  • Italic: or
  • Underline:
1
likes
0
points
37
downloads

Publisher

unverified uploader

Weekly Downloads

flutter_text_parser is a Dart library that allows you to parse any string with custom tags and render it as styled spanned text. It supports inline formatting like bold, italic, colors, and more, making it easy to transform plain tagged text (e.g., <b><i>Flutter</i></b> is <color:red>awesome.</color>) into richly styled widgets in Flutter.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flutter_text_parser