Advertisement
rajath_pai

flutter TextField

Aug 1st, 2021
1,368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.80 KB | None | 0 0
  1. //Try it out
  2. //The text field changes color when it is pressed
  3.  
  4. import 'package:flutter/material.dart';
  5.  
  6. void main() => runApp(MyApp());
  7.  
  8. class MyApp extends StatelessWidget {
  9.   @override
  10.   Widget build(BuildContext context) {
  11.     return MaterialApp(
  12.       title: 'Flutter TextInput Border Color Example',
  13.       home: FlutterExample(),
  14.     );
  15.   }
  16. }
  17.  
  18. class FlutterExample extends StatefulWidget {
  19.   @override
  20.   _FlutterExampleState createState() => _FlutterExampleState();
  21. }
  22.  
  23. class _FlutterExampleState extends State<FlutterExample> {
  24.   final myController = TextEditingController();
  25.  
  26.   @override
  27.   void dispose() {
  28.     myController.dispose();
  29.     super.dispose();
  30.   }
  31.  
  32.   @override
  33.   Widget build(BuildContext context) {
  34.     return Scaffold(
  35.         appBar: AppBar(
  36.           title: Text('TextField Border Color'),
  37.         ),
  38.         body: Padding(
  39.           padding: EdgeInsets.all(16),
  40.             child: new Theme(
  41.               data: new ThemeData(
  42.                 primaryColor: Colors.redAccent,
  43.                 primaryColorDark: Colors.red,
  44.               ),
  45.               child: new TextField(
  46.                 decoration: new InputDecoration(
  47.                     border: new OutlineInputBorder(
  48.                         borderSide: new BorderSide(color: Colors.teal)),
  49.                     hintText: 'Tell us about yourself',
  50.                     helperText: 'Keep it short, this is just a demo.',
  51.                     labelText: 'Life story',
  52.                     prefixIcon: const Icon(
  53.                       Icons.person,
  54.                       color: Colors.green,
  55.                     ),
  56.                     prefixText: ' ',
  57.                     suffixText: 'USD',
  58.                     suffixStyle: const TextStyle(color: Colors.green)),
  59.               ),
  60.         ))
  61.     );
  62.   }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement