read_more_codespark 0.0.11

SDKflutter
Platformandroidioswindowslinuxmacosweb

Tired of truncated text? read_more_codespark offers a simple and customizable solution for displaying expandable text in your Flutter projects.

Banner

📖 read_more_codespark

Pub Version GitHub

A lightweight and customizable Flutter widget for displaying expandable and collapsible text. Ideal for handling lengthy content in a clean and user-friendly manner.


✨ Features

  • Expandable Text: Truncate text after a specified number of lines with an option to expand/collapse.
  • Customization: Adjust text style, alignment, overflow behavior, and locale settings.
  • Animations: Choose between size or cross-fade animations for transitions.
  • Icons: Optional toggle icons with customizable colors.
  • Callbacks: Receive updates on toggle state changes.

🚀 Installation

Add the following to your pubspec.yaml:

dependencies:
  read_more_codespark: ^0.0.5

Then, run:

flutter pub get

🧪 Usage

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Read More Example')),
        body: const Padding(
          padding: EdgeInsets.all(16.0),
          child: ReadMoreCodeSpark(
            text:
                "This is a long text that will be truncated and shown with a 'show more' indicator. Tapping the indicator will reveal the full content. You can customize the text style, minimum lines displayed, and overflow behavior.",
            textStyle: TextStyle(fontSize: 16.0),
            maxLines: 2,
          ),
        ),
      ),
    );
  }
}

📷 Screenshots

Read More Read Less

🛠️ Parameters

ParameterDescriptionDefault
textThe text content to display.—
textStyleStyle for the main text.null
maxLinesNumber of lines to display before truncation.2
readMoreTextText for the "Read more" link.'Read more'
readLessTextText for the "Read less" link.'Read less'
readMoreStyleStyle for the "Read more" text.null
readLessStyleStyle for the "Read less" text.null
textAlignAlignment of the text.TextAlign.start
textOverflowOverflow behavior of the text.TextOverflow.ellipsis
localeLocale for the text.null
iconToggleWhether to show toggle icons.true
iconColorColor of the toggle icons.null
animatedWhether to animate the expansion/collapse.true
animationDurationDuration of the animation.Duration(milliseconds: 100)
animationTypeType of animation (size or crossFade).AnimationType.size
onToggleCallback when the toggle state changes.null

🧩 Example

An example project is available in the example/ directory. To run it:

git clone https://github.com/Katayath-Sai-Kiran/read_more_codespark.git
cd read_more_codespark/example
flutter run

📝 Changelog

All notable changes to this project will be documented in the CHANGELOG.md file.

🐛 Issues & Feedback

If you encounter any issues or have suggestions for improvements, please create an issue on GitHub. Contributions are welcome!

👨‍💻 Maintainer

Developed with ❤️ by Katayath Sai Kiran. Feel free to reach out or contribute to the project.