Flutter (Dart) How to add copy to clipboard on tap to a app?

If you want better solution without any dependency that working async use this:

import 'package:flutter/services.dart';

Clipboard.setData(ClipboardData(text: email)).then((_){
    ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("Email address copied to clipboard")));
});

There was breaking changes that you might find useful in the following link: https://docs.flutter.dev/release/breaking-changes/scaffold-messenger


import:

import 'package:flutter/services.dart';

And then Simply implement this:

onTap: () {
  Clipboard.setData(ClipboardData(text: "your text"));
},

Tags:

Dart

Flutter