Flutter – Clipboard
- 2021年9月10日
- 技術情報
This week also let’s learn flutter new things. I will show you how to copy and paste a text with flutter. Let’s start coding.
First thing we need to do is add this clipboard package in pubspec.yaml file.
flutter pub add clipboard
Copy to clipboard
FlutterClipboard.copy(field.text).then(( value ) => print('copied'));
Paste from clipboard
FlutterClipboard.paste().then((value) {
// Do what ever you want with the value.
setState(() {
field.text = value;
pasteValue = value;
});
});
For text editing field :
TextEditingController field = TextEditingController();
TextFormField(
controller: field,
decoration: const InputDecoration(
hintText: 'Enter text'
),
),
Hope you enjoyed this article!
By ami
asahi at 2021年09月10日 10:00:00