Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/services.dart';
  3.  
  4. class CopyableReadOnlyTextField extends StatelessWidget {
  5. const CopyableReadOnlyTextField({
  6. Key key,
  7. @required this.label,
  8. @required this.textValue,
  9. }) : super(key: key);
  10.  
  11. final String label;
  12. final String textValue;
  13. @override
  14. Widget build(BuildContext context) {
  15. return TextField(
  16. readOnly: true,
  17. controller: TextEditingController(text: textValue),
  18. decoration: InputDecoration(
  19. labelText: label,
  20. suffixIcon: IconButton(
  21. icon: Icon(Icons.content_copy),
  22. onPressed: () {
  23. Clipboard.setData(ClipboardData(text: textValue));
  24. },
  25. ),
  26. ),
  27. );
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement