auto_size_text icon indicating copy to clipboard operation
auto_size_text copied to clipboard

Option to make text selectable?

Open jdeltoft opened this issue 5 years ago • 7 comments

Awesome package!! One thing I would like if you could is to make the text selectable in my browser, such as if I use it to show text like an email address that they may want to cut and paste.

jdeltoft avatar Feb 19 '20 18:02 jdeltoft

This could be a huge added value to the plugin. If there's anything that can be done to help, let us know.

ElZombieIsra avatar Jun 25 '20 03:06 ElZombieIsra

I would also be interested in this option. It would be great to have a true or false parameter for selectable text.

Cubel89 avatar Sep 01 '20 15:09 Cubel89

Any update on this please ?

loic-hamdi avatar Apr 08 '21 19:04 loic-hamdi

The selectable text feature is available in auto_size_text ? Please update

adithya421 avatar Feb 10 '22 09:02 adithya421

This package is awesome, but incompatibility with SelectableText is definitely missing. +1 for considering adding this feature.

DSD3V avatar Oct 09 '22 04:10 DSD3V

Since Flutter 3.3 you can use SelectionArea which makes every Text widget selectable.

Code:

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      darkTheme: ThemeData.dark(),
      theme: ThemeData.light(),
      home: const MyHomePage(),
      debugShowCheckedModeBanner: false,
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Flutter app'),
      ),
      body: const Center(
        child: SelectionArea( // Add this widget
          child: AutoSizeText(
            'The text to display',
            style: TextStyle(fontSize: 20),
            maxLines: 2,
          ),
        ),
      ),
    );
  }
}

Demo:

https://user-images.githubusercontent.com/24459435/194749724-ad873b43-b253-4258-a98f-b529119ed47e.mov

So I think we can close this issue.

nilsreichardt avatar Oct 09 '22 09:10 nilsreichardt

@nilsreichardt Yep, SelectableText will be deprecated in near future, so we can close it safely.

PcolBP avatar Oct 09 '22 12:10 PcolBP