custom_text 0.0.1 icon indicating copy to clipboard operation
custom_text: ^0.0.1 copied to clipboard


A text widget that enables strings in it to be styled flexibly and/or tapped.


import 'package:flutter/material.dart';

import 'package:custom_text_example/examples/example1.dart';
import 'package:custom_text_example/examples/example2.dart';
import 'package:custom_text_example/examples/example3.dart';
import 'package:custom_text_example/examples/example4.dart';
import 'package:custom_text_example/examples/example5.dart';
import 'package:custom_text_example/examples/example6.dart';

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

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'CustomText Demo',
      theme: ThemeData(
        primarySwatch: Colors.teal,
        textTheme: const TextTheme(
          bodyText2: TextStyle(fontSize: 18.0, height: 1.5),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('CustomText'),
        body: ListView(
          children: [
              title: 'Simple',
              builder: (title) => Example1(
                'A very basic example with URLs and email addresses styled.\n'
                    'They are not tappable in this example.',
              title: 'Unique styles and actions',
              builder: (title) => Example2(
                'An example to apply styles to URLs, email addresses and '
                    'phone numbers, and enable them to be tapped / '
                    'All of the three are styled, but only phone numbers '
                    'among them are given unique `matchStyle` and `tapStyle`.',
              title: 'Overwritten match pattern',
              builder: (title) => Example3(
                'An example to overwrite the default match pattern of '
                    'The new pattern regards only the `{3 digits}-{4 digits}'
                    '-{4 digits}` format as a phone number.',
              title: 'Custom matchers',
              builder: (title) => Example4(
                'An example to parse hashtags using a custom matcher and '
                    'apply styles to them.\n'
                    'A hashtag has a wide variety of definitions, but here '
                    'as an example, it is defined as a string that starts '
                    'with `#` followed by an alphabet and then by '
                    'alphanumerics, and is enclosed with white spaces.',
              title: 'SelectiveDefinition',
              builder: (title) => Example5(
                  'An example to parse markdown-style links, like [label](url) '
                      'using `SelectiveDefinition`, and make them tappable.\n'
                      'Each of the string shown in the widget and the string '
                      'passed to the tap callbacks is selected individually '
                      'from the fragments (`groups`) that have matched the'
                      'patterns enclosed with parentheses within the match '
              title: 'SpanDefinition',
              builder: (title) => Example6(
                'An example to show both strings and icons using '
                    'The builder parameter takes a function returning an '
                    'The function is provided with matched string and groups, '
                    'so it is possible to construct an `InlineSpan` flexibly '
                    'with them.',

class _ListTile extends StatelessWidget {
  const _ListTile({@required this.title, @required this.builder});

  final String title;
  final Widget Function(String title) builder;

  Widget build(BuildContext context) {
    return ListTile(
      title: Text(title),
      trailing: const Icon(Icons.arrow_forward),
      onTap: () => Navigator.of(context).push<void>(
        MaterialPageRoute(builder: (_) => builder(title)),
pub points


verified publisher

A text widget that enables strings in it to be styled flexibly and/or tapped.

Repository (GitHub)
View/report issues


Icon for licenses.unknown (LICENSE)


flutter, text_parser


Packages that depend on custom_text