rich_text_controller 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • new61

rich_text_controller #

An extended text editing controller that supports different inline styles for custom regex

Getting Started #

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

dependencies:
  pagarme_flutter_card_hash: [latest version]

Import it

import'rich_text_controller/rich_text_controller.dart';

Demo #

Usage #

import 'package:flutter/material.dart';  
import 'rich_text_controller/rich_text_controller.dart';  
  
void main() => runApp(MyApp());  
  
class MyApp extends StatelessWidget {  
  @override  
  Widget build(BuildContext context) {  
    return MaterialApp(  
      title: 'RichText Controller Demo',  
      theme: ThemeData(  
        primarySwatch: Colors.blue,  
      ),  
      home: RichTextControllerDemo(),  
    );  
  }  
}  
  
class RichTextControllerDemo extends StatefulWidget {
  @override
  _RichTextControllerDemoState createState() => _RichTextControllerDemoState();
}

class _RichTextControllerDemoState extends State<RichTextControllerDemo> {

// Add a controller
RichTextController _controller;

  @override
  void initState() {
      // initialize with your custom regex patterns and styles
      _controller = RichTextController({
           //
          //* Returns every Hashtag with red color
          //
          RegExp(r"\B#[a-zA-Z0-9]+\b"):TextStyle(color:Colors.red),
         // add as many expressions as you need!
      });
    super.initState();
  }
}

[1.0.0] - First Released! #

[1.0.1] - Added Example. #

example/README.md

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

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

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

class RichTextControllerDemo extends StatefulWidget {
  @override
  _RichTextControllerDemoState createState() => _RichTextControllerDemoState();
}

class _RichTextControllerDemoState extends State<RichTextControllerDemo> {

// Add a controller
RichTextController _controller;

  @override
  void initState() {
      // initialize with your custom regex patterns and styles
      _controller = RichTextController({
           //
          //* Returns every Hashtag with red color
          //
          RegExp(r"\B#[a-zA-Z0-9]+\b"):TextStyle(color:Colors.red),
           //
          //* Returns every Mention with blue color and bold style.
          //
          RegExp(r"\B@[a-zA-Z0-9]+\b"):TextStyle(fontWeight: FontWeight.w800 ,color:Colors.blue,),
           //
          //* Returns every word after '!' with yellow color and italic style.
          //
          RegExp(r"\B![a-zA-Z0-9]+\b"):TextStyle(color:Colors.yellow, fontStyle:FontStyle.italic),
         // add as many expressions as you need!
      });
    super.initState();
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  rich_text_controller: ^1.0.1

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:rich_text_controller/rich_text_controller.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
23
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]
61
Learn more about scoring.

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

  • Dart: 2.8.1
  • pana: 0.13.8-dev
  • Flutter: 1.17.0

Health suggestions

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

Analysis of lib/rich_text_controller.dart reported 2 hints:

line 17 col 16: This function has a return type of 'String', but doesn't end with a return statement.

line 28 col 19: This function has a return type of 'String', but doesn't end with a return statement.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test