flutter copy to clipboard code example
Example 1: copy to clipboard flutter
import 'package:flutter/services.dart';
ClipboardData data = ClipboardData(text: '<Text to copy goes here>');
await Clipboard.setData(data);
Example 2: button copy to clipboard flutter
Container(
width: double.maxFinite,
child: RaisedButton.icon(
color: Colors.blue,
onPressed: () {
var data = jsonEncode(command.dioError);
Clipboard.setData(ClipboardData(text: data.toString()));
snackBar();
},
label: Text('Copy error to clipboard', style: TextStyle(color: Colors.white)),
icon: Icon(Icons.copy, color: Colors.white),
textColor: Colors.white,
splashColor: Colors.blueAccent,
),
),
Example 3: clipboard flutter
dependencies:
clipboard: ^0.1.2+8
Example 4: Copy URL To Clipboard by flutter
Copy URL To Clipboard by flutter