import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
// Main application widget
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'GFG - Disable TextFormField Options',
debugShowCheckedModeBanner: false,
home: Home(),
);
}
}
// Home screen widget
class Home extends StatelessWidget {
const Home({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Disable TextFormField Options"),
backgroundColor: Colors.green,
foregroundColor: Colors.white,
),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Default TextFormField with no restrictions
TextFormField(
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: "Default TextField",
),
keyboardType: TextInputType.text,
),
const SizedBox(
height: 50,
),
// TextFormField with interactive selection disabled
TextFormField(
// Disabling text selection options
enableInteractiveSelection: false,
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: "Options Disabled TextField",
),
keyboardType: TextInputType.text,
)
],
),
),
);
}
}