Reputation: 301
I am trying to access the Clipboard in Flutter, but I encounter the following error:
Class or object does not exist.
Am I missing an import?
I tried the following:
import 'package:flutter/material.dart';
Clipboard.setData();
Upvotes: 1
Views: 920
Reputation: 7548
Answer Updated :
Import :
import 'package:flutter/services.dart';
And implement this :
IconButton(
icon: Icon(
Icons.content_copy,
color: Colors.blue,
),
onPressed: () {
Clipboard.setData(ClipboardData(text: "your text"));
}
),
Upvotes: 3
Reputation: 126734
You need to import flutter/services.dart
:
import 'package:flutter/services.dart';
Now, you can access Clipboard.setData
.
Upvotes: 1