flutter how to copy a text when click a button code example

Example 1: 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 2: flutter how to copy a text when click a button

ClipboardManager.copyToClipBoard(valueText) // This

Tags:

Misc Example