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

A Flutter widget for collapsed and expandable text with configurable links, animations, styles, mentions, hashtags, and URL taps.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Expandable Text Demo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final ExpandableTextController _controller = ExpandableTextController();

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Expandable Text')),
      body: Padding(
        padding: const EdgeInsets.all(15.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            ExpandableText(
              'Short text',
              expandText: 'show more',
              collapseText: 'show less',
            ),
            SizedBox(height: 10.0),
            ExpandableText(
              'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
              expandText: 'show more',
              collapseText: 'show less',
              maxLines: 1,
              linkColor: Colors.blue,
            ),
            SizedBox(height: 10.0),
            ExpandableText(
              'This text can be controlled from buttons outside the widget. Tap anywhere on the text bounds to expand it, or use the buttons below.',
              controller: _controller,
              expandText: 'show more',
              collapseText: 'show less',
              expandOnTextTap: true,
              collapseOnTextTap: true,
              animation: true,
            ),
            Row(
              children: <Widget>[
                TextButton(
                  onPressed: _controller.expand,
                  child: Text('expand'),
                ),
                TextButton(
                  onPressed: _controller.collapse,
                  child: Text('collapse'),
                ),
              ],
            ),
          ],
        ),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
1
likes
150
points
26
downloads
screenshot

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter widget for collapsed and expandable text with configurable links, animations, styles, mentions, hashtags, and URL taps.

Repository (GitHub)
View/report issues

Topics

#expandable-text #read-more #flutter-widget #text #ui

License

MIT (license)

Dependencies

flutter

More

Packages that depend on expandable_text_x