Customizing Text Field
Complete Code For Customizing Text Field In Flutter
main.dart
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Retrieve Text Input', home: MyHomePage(), ); } } class MyHomePage extends StatefulWidget{ @override State<StatefulWidget> createState() => MyHomePageState(); } class MyHomePageState extends State<MyHomePage>{ @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData.dark(), title: "My Text Field", home: Scaffold( body: Padding( padding: EdgeInsets.symmetric(horizontal: 24.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ TextField( decoration: InputDecoration( enabledBorder: OutlineInputBorder( borderSide: BorderSide( color: Colors.blueAccent, ), borderRadius: BorderRadius.circular(10.0), ), hintText: "Enabled decoration text ...", )), SizedBox(height: 10), TextField( decoration: InputDecoration( disabledBorder: OutlineInputBorder( borderSide: BorderSide( color: Colors.grey, ), borderRadius: BorderRadius.circular(10.0), ), hintText: "Disabled decoration text ...", ), enabled: false, ), SizedBox(height: 10), TextField( decoration: InputDecoration( errorBorder: OutlineInputBorder( borderSide: BorderSide( color: Colors.red, ), borderRadius: BorderRadius.circular(10.0), ), hintText: "Error decoration text ...", errorText: "Ooops, something is not right!", errorStyle: TextStyle( color: Colors.red, fontWeight: FontWeight.bold)), ), SizedBox(height: 10), TextField( decoration: InputDecoration( focusedBorder: OutlineInputBorder( borderSide: BorderSide( color: Colors.blue, ), borderRadius: BorderRadius.circular(10.0), ), hintText: "Focus decoration text ...", ), ), SizedBox(height: 10), TextField( decoration: InputDecoration( border: OutlineInputBorder( borderSide: BorderSide( color: Colors.red,//this has no effect ), borderRadius: BorderRadius.circular(10.0), ), hintText: "Border decoration text ...", ), ) ], )), )); } }