super_rich_text 0.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 81

Super Rich Text #

Check it out at Pub.Dev

The easiest way to style custom text snippets

ezgif com-video-to-gif-3

Defaults #

In standard markers the "*" is set to bold and "/" to italics as in the example:

SuperRichText(
  text: 'Text in *bold* and /italic/'
)

Others Markers #

But you can change and set your own by passing a list of other labels:

SuperRichText(
  text: 'Text in *bold* and /italic/ with color llOrangell and color rrRedrr',
  style: TextStyle(
    color: Colors.black87,
    fontSize: 22
  ),
  othersMarkers: [
    MarkerText(
      marker: 'll',
      style: TextStyle(
        color: Colors.orangeAccent
      )
    ),
    MarkerText(
      marker: 'rr',
      style: TextStyle(
          color: Colors.redAccent
      )
    ),
  ],
)

Override Global Markers #

Or even override "*" and "/" by setting global styles not to be used:

SuperRichText(
  text: 'Text in *bold* and /italic/ with color llOrangell and color rrRedrr',
  useGlobalMarkers: false, // set false
  style: TextStyle(
    color: Colors.black87,
    fontSize: 22
  ),
  othersMarkers: [
    MarkerText(
        marker: '*',
        style: TextStyle(
            color: Colors.orangeAccent
        )
    )...
  ],
)

Global Markers #

The markers in the "othersMarkers" parameter are only for the widget in question, but you can also distinguish global markers:

SuperRichText.globalMarkerTexts.add(MarkerText(
    marker: '|',
    style: TextStyle(
      color: Colors.deepPurple
    )
  )
);

It is also possible to insert functions or links directly into the text:

MarkerText.withUrl(
  marker: 'll',
  urls: [
    'https://www.google.com',
    'https://www.facebook.com'
  ],
  style: TextStyle(
    fontSize: 36,
    color: Colors.orangeAccent
  )
)

In this case, the link list should be in exactly the same sequence as the links within the text, having as base text: "this text has llLink1ll and llLink2ll", the example above would set Link1 as 'https://www.google.com' and Link2 as 'https://www.facebook.com'. Another point is that it already has a bold style and blue text by default.

Functions #

With functions, the sequence is also the same, but the call should look like this:

MarkerText.withFunction(
  marker: 'ff',
  functions: [
    () => print('function 1'),
    () => print('function 2')
  ],
  style: TextStyle(
    color: Colors.greenAccent
  )
)

[0.1.0] - TODO: Add release date. #

  • TODO: Describe initial release.

[0.1.0+1] - Fixing description length #

  • Now is possible add links and functions in same text.

example/main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Main(),
    );
  }
}

class Main extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    //To add global markers
    SuperRichText.globalMarkerTexts.add(MarkerText(
        marker: '|',
        style: TextStyle(
          color: Colors.deepPurple
        )
      )
    );

    return Scaffold(
      body: Center(
          child: SuperRichText(
            text: 'Text in *bold* and /italic/ with color ooOrangeoo and color rrRedrr, llLink1ll llLink2ll, ffFunction1ff ffFunction2ff',
            style: TextStyle(
                color: Colors.black87,
                fontSize: 22
            ),
            othersMarkers: [
              MarkerText(
                  marker: 'oo',
                  style: TextStyle(
                      color: Colors.orangeAccent
                  )
              ),
              MarkerText(
                  marker: 'rr',
                  style: TextStyle(
                      color: Colors.redAccent
                  )
              ),
              MarkerText.withUrl(
                  marker: 'll',
                  urls: [
                    'https://www.google.com',
                    'https://www.facebook.com'
                  ]
              ),
              MarkerText.withFunction(
                  marker: 'ff',
                  functions: [
                        () => print('function 1'),
                        () => print(('function 2'))
                  ],
                  style: TextStyle(
                      color: Colors.greenAccent
                  )
              )
            ],
          )
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  super_rich_text: ^0.2.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:super_rich_text/super_rich_text.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
63
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
81
Learn more about scoring.

We analyzed this package on Feb 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.8

Health issues and suggestions

Document public APIs. (-0.25 points)

38 out of 39 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/super_rich_text.dart. (-1 points)

Analysis of lib/super_rich_text.dart reported 2 hints:

line 117 col 29: Avoid using unnecessary statements.

line 132 col 29: Avoid using unnecessary statements.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
url_launcher ^5.2.5 5.4.2
Transitive dependencies
collection 1.14.11 1.14.12
flutter_web_plugins 0.0.0
meta 1.1.8
plugin_platform_interface 1.0.2
sky_engine 0.0.99
typed_data 1.1.6
url_launcher_macos 0.0.1+4
url_launcher_platform_interface 1.0.6
url_launcher_web 0.1.1+1
vector_math 2.0.8
Dev dependencies
flutter_test