Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- class CopyableReadOnlyTextField extends StatelessWidget {
- const CopyableReadOnlyTextField({
- Key key,
- @required this.label,
- @required this.textValue,
- }) : super(key: key);
- final String label;
- final String textValue;
- @override
- Widget build(BuildContext context) {
- return TextField(
- readOnly: true,
- controller: TextEditingController(text: textValue),
- decoration: InputDecoration(
- labelText: label,
- suffixIcon: IconButton(
- icon: Icon(Icons.content_copy),
- onPressed: () {
- Clipboard.setData(ClipboardData(text: textValue));
- },
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement