customizable_text 0.1.2 copy "customizable_text: ^0.1.2" to clipboard
customizable_text: ^0.1.2 copied to clipboard

A widget that can customize text style for specific texts based on RichText. It's simple, easy to use, and intuitive.

Customizable Text #

Customize a style of random words based on RichText.

Installation #

dependencies:
  customizable_text: ^0.1.0

Usage #

Basic usage #

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: const Text("Customizable Text Sample"),
    ),
    body: Padding(
      padding: const EdgeInsets.all(24),
      child: CustomizableText(
        originalText,
        style: const TextStyle(
          color: Colors.grey,
        ),
        customStyle: const TextStyle(
          color: Colors.blue,
          fontWeight: FontWeight.w500,
        ),
        customizes: const [
          CustomText('Terms of Service'),
          CustomText('Privacy Policy'),
          CustomText('Cookie Use'),
          CustomText('Privacy Policy'),
          CustomText('Learn more'),
          CustomText('here'),
        ],
      ),
    ),
  );
}

Dynamic customizing #

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: const Text("Customizable Text Sample"),
    ),
    body: Padding(
      padding: const EdgeInsets.all(24),
      child: CustomizableText(
        originalText,
        style: const TextStyle(
          color: Colors.grey,
        ),
        customStyle: const TextStyle(
          color: Colors.blue,
          fontWeight: FontWeight.w500,
        ),
        customizes: [
          const CustomText(
            'Terms of Service',
            style: TextStyle(
              color: Colors.red,
              fontWeight: FontWeight.w600,
            ),
          ),
          CustomText(
            'Privacy Policy',
            style: const TextStyle(
              color: Colors.green,
              fontSize: 18,
            ),
            onTap: (text) => print(text),
          ),
          CustomText(
            'Cookie Use',
            style: const TextStyle(
              color: Colors.orange,
              fontSize: 20,
              fontWeight: FontWeight.bold,
              fontStyle: FontStyle.italic,
              decoration: TextDecoration.underline,
              decorationColor: Colors.orange,
            ),
            onTap: (text) => print(text),
          ),
          const CustomText(
            'Privacy Policy',
            style: TextStyle(
              color: Colors.black,
              fontWeight: FontWeight.bold,
              decoration: TextDecoration.lineThrough,
              decorationColor: Colors.red,
              decorationThickness: 2,
            ),
          ),
          const CustomText('Learn more'),
          const CustomText('here'),
        ],
      ),
    ),
  );
}

Customize just for the second span word #

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: const Text("Customizable Text Sample"),
    ),
    body: Padding(
      padding: const EdgeInsets.all(24),
      child: CustomizableText(
        originalText,
        style: const TextStyle(
          color: Colors.grey,
        ),
        customStyle: const TextStyle(
          color: Colors.blue,
          fontWeight: FontWeight.w500,
        ),
        customizes: const [
          CustomText(
            'Privacy Policy',
            span: 1,
            style: TextStyle(
              color: Colors.black,
              fontWeight: FontWeight.bold,
              decoration: TextDecoration.lineThrough,
              decorationColor: Colors.red,
              decorationThickness: 2,
            ),
          ),
        ],
      ),
    ),
  );
}

License #

MIT

5
likes
150
pub points
0%
popularity

Publisher

unverified uploader

A widget that can customize text style for specific texts based on RichText. It's simple, easy to use, and intuitive.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on customizable_text