Skip to content

Instantly share code, notes, and snippets.

@ericorruption
Created February 21, 2020 09:35
Show Gist options
  • Save ericorruption/3ce20c83ed6f1738d3989c543a4ab2e8 to your computer and use it in GitHub Desktop.
Save ericorruption/3ce20c83ed6f1738d3989c543a4ab2e8 to your computer and use it in GitHub Desktop.
readOnly textField - cannot copy text
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
body: Padding(
padding: EdgeInsets.all(24),
child: Center(
child: TextField(
readOnly: true,
controller: TextEditingController(text:
'line 1\n'
'\n'
'\n'
'line last'
),
),
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment