In this example, we are going to show you the way to disable copy, cut, paste, and select all toolbar on TextField widget. You may need to disable these toolbar on your app, see the example below for more details:
TextField(
toolbarOptions: ToolbarOptions(
copy:false,
paste: false,
cut: false,
selectAll: true
//by default all are disabled 'false'
),
)
import 'package:flutter/material.dart';
void main(){
runApp(MyApp());
}
class MyApp extends StatelessWidget{
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Home(),
);
}
}
class Home extends StatelessWidget{
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Copy & Paste with Dart"),
backgroundColor: Colors.indigoAccent,
),
body: Container(
alignment: Alignment.center,
padding: EdgeInsets.all(20),
child: Column(children: [
TextField(
toolbarOptions: ToolbarOptions(
copy:false,
paste: false,
cut: false,
selectAll: true
//by default all are disabled 'false'
),
decoration: InputDecoration(
labelText: "Disabled Copy & Paste"
),
),
TextField(
toolbarOptions: ToolbarOptions(
selectAll:false,
copy: true,
cut: true,
paste: true,
),
decoration: InputDecoration(
labelText: "Disabled Select All"
),
),
],)
)
);
}
}
In this way, you can disable copy, paste, cut, select all toolbar on TextField widget in Flutter apps.
Please Wait...
No any Comments on this Article