My Custom Text Package

A lightweight Flutter package providing a next-gen customizable text widget and utility classes for reusable UI components.

Features

  • Fully customizable font, size, color, letter spacing, word spacing
  • Handles text overflow and max lines
  • Selectable text support
  • RichText support for mentions (@user), hashtags (#flutter), and emojis
  • Tap callbacks per word/mention/hashtag
  • Gradient text support and animated gradients
  • Shadow and glow effects
  • Predefined style presets (title, subtitle, body, caption, buttonText)
  • Pub.dev-ready textScaler for non-linear text scaling

Requirements

  • Flutter 3.12 or higher

Installation

Add this to your pubspec.yaml:

dependencies:
  my_custom_text_package: ^0.0.8

Usage

  1. Basic Text
CustomTextWidget(
  text: 'Hello Flutter!',
  fontSize: 20,
  fontWeight: FontWeight.bold,
  color: Colors.deepPurple,
  textAlign: TextAlign.center,
);
  1. Rich Text with Mentions & Hashtags
CustomTextWidget(
  text: 'Hello @user! Check out #Flutter',
  richTextMode: true,
  onTapWord: (word) {
    if (word.startsWith('@')) print('Tapped mention: $word');
    if (word.startsWith('#')) print('Tapped hashtag: $word');
  },
  fontSize: 18,
  fontWeight: FontWeight.w500,
  color: Colors.black87,
);
  1. Gradient Text
CustomTextWidget(
  text: 'Gradient Text Example',
  fontSize: 24,
  fontWeight: FontWeight.bold,
  gradient: LinearGradient(
    colors: [Colors.blue, Colors.purple],
  ),
);
  1. Animated Gradient Text
CustomTextWidget(
  text: "Gradient Text 🌈",
  gradient: const LinearGradient(
    colors: [Colors.purple, Colors.blue, Colors.teal],
  ),
  animatedGradient: true,
  preset: TextPresets.title,
);
  1. Text with Shadows
CustomTextWidget(
  text: 'Text with Shadow',
  fontSize: 24,
  fontWeight: FontWeight.bold,
  shadows: const [
    Shadow(
    color: Colors.black26,
    offset: Offset(2, 2),
    blurRadius: 4,
    ),
  ],
);
  1. Selectable Text
CustomTextWidget(
  text: 'You can select this text!',
  selectable: true,
  fontSize: 18,
  color: Colors.teal,
);
  1. Using Preset Styles
CustomTextWidget(
  text: 'Title Preset',
  preset: TextPresets.title,
);

CustomTextWidget(
  text: 'Subtitle Preset',
  preset: TextPresets.subtitle,
);