rich_text_controller 1.1.0 copy "rich_text_controller: ^1.1.0" to clipboard
rich_text_controller: ^1.1.0 copied to clipboard

outdated

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

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!

         //! starting v1.1.0
         // Now you have an onMatch callback that gives you access to a List<String>
         // which contains all matched strings
         onMatch: (List<String> matches){
           // Do something with matches.
           //! P.S
           // as long as you're typing, the controller will keep updating the list.
         }
         //!
      });
    super.initState();
  }
}
84
likes
0
pub points
95%
popularity

Publisher

verified publishermicazi.dev

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

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on rich_text_controller