'Is there a possibility to put textButton when text is overflowing?

I have Text with overflow: TextOverflow.ellipsis.

As you can see below, text is overflowing. I want to make TextButton instead or after overflowing but only when text is overflowing. I tried to do this with Text.rich and TextSpan but when Text is overflowing TextButton is not appearing.

It's possible to do something like this?

enter image description here



Solution 1:[1]

As much as I understood, you can use the readmore package.

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

class ReadMoreScreen extends StatelessWidget {
  const ReadMoreScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: Text('Read More')),
        body: Column(children: [
          ReadMoreText(
            'Flutter is Google’s mobile UI open source framework to build high-quality native (super fast) interfaces for iOS and Android apps with the unified codebase.',
            style: TextStyle(color: Colors.black),
            trimLines: 2,
            colorClickableText: Colors.pink,
            trimMode: TrimMode.Line,
            trimCollapsedText: 'Show more',
            trimExpandedText: ' show less',
            callback: (change) {
              print(change);
            },
          ),
        ]));
  }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1