Ad
Flutter - Paste Text Over Other Text Already Written In A TextField
I have a program that copies and pastes text in flutter, the problem is that when I copy the text and paste it, it replaces the one that was previously written, in this case I want to write over the text already written before and that it is pasted with a space, like a normal copy and paste. I hope your help, thank you.
TextEditingController textEditingController;
String paste = '';
_textField() {
return SliverToBoxAdapter(
child: Padding(
padding: EdgeInsets.all(30.0),
child: TextFormField(
controller: textEditingController,
),
),
);
}
_buttons() {
return SliverToBoxAdapter(
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
IconButton(
icon: Icon(Icons.content_copy),
onPressed: () async {
await FlutterClipboard.copy(textEditingController.text);
Scaffold.of(context).showSnackBar(
SnackBar(content: Text('✓ Copied to Clipboard')),
);
},
),
IconButton(
icon: Icon(Icons.paste),
onPressed: () async {
final value = await FlutterClipboard.paste();
setState(() {
this.paste = value;
});
},
)
],
),
SizedBox(
height: 20,
),
Text(
'Clipboard Text',
style: TextStyle(fontSize: 20),
)
],
),
);
}
Ad
Answer
you must add the copied value to the current value.
Try this
setState(() {
this.paste = '${this.paste}, $value';
});
Ad
source: stackoverflow.com
Related Questions
- → How do you create a 12 or 24 mnemonics code for multiple cryptocurrencies (ETH, BTC and so on..)
- → Flutter: input text field don't work properly in a simple example..... where am I wrong?
- → Can I customize the code formatting of Dart code in Atom?
- → Is it possible to develop iOS apps with Flutter on a Linux virtual machine?
- → Display SnackBar in Flutter
- → JSON ObjectMapper in Flutter
- → Material flutter app source code
- → TabBarSelection No such method error
- → How do I set the animation color of a LinearProgressIndicator?
- → Add different routes/screens to Flutter app
- → Is there a way to get the size of an existing widget?
- → How to share a file using flutter
- → Is there an easy way to find particular text built from RichText in a Flutter test?
Ad