simc / auto_size_text

Flutter widget that automatically resizes text to fit perfectly within its bounds.
https://pub.dev/packages/auto_size_text
MIT License
2.06k stars 241 forks source link

Option to make text selectable? #49

Open jdeltoft opened 4 years ago

jdeltoft commented 4 years ago

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.

ElZombieIsra commented 4 years ago

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

Cubel89 commented 4 years ago

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

loic-hamdi commented 3 years ago

Any update on this please ?

adithya421 commented 2 years ago

The selectable text feature is available in auto_size_text ? Please update

DSD3V commented 2 years ago

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

nilsreichardt commented 2 years ago

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.

PcolBP commented 2 years ago

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