Copy text in Flutter | Copy to clipboard Text in Flutter

Flutter

In Flutter, copying text from your app can be achieved through various techniques. One of the simplest methods is using the SelectableText widget. This widget offers an easy way to enable text copying in your Flutter application.

SelectableText("text which you want to copy")

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('SelectableText Example'),
        ),
        body: Center(
          child: Padding(
            padding: const EdgeInsets.all(20.0),
            child: SelectableTextExample(),
          ),
        ),
      ),
    );
  }
}

class SelectableTextExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SelectableText(
      'This is selectable text. Long press to select and copy.',
      style: TextStyle(fontSize: 18.0),
    );
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

web_horizontal
About Us ♢ Disclaimer ♢ Privacy Policy ♢ Terms & Conditions ♢ Contact Us

Copyright © 2023 ResearchThinker.com. All rights reserved.