text form field flutter
TextField(
onChanged: (value) {
//Do something with the user input.
},
decoration: InputDecoration(
hintText: 'Enter your password.',
contentPadding:
EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(32.0)),
),
enabledBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.lightBlueAccent, width: 1.0),
borderRadius: BorderRadius.all(Radius.circular(32.0)),
),
focusedBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.lightBlueAccent, width: 2.0),
borderRadius: BorderRadius.all(Radius.circular(32.0)),
),
),
),
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 StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
// var to store
// onChanged callback
String title;
String text = "No Value Entered";
void _setText() {
setState(() {
text = title;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('GeeksforGeeks'),
backgroundColor: Colors.green,
),
body: Column(
children: [
Padding(
padding: const EdgeInsets.all(15),
child: TextField(
decoration: InputDecoration(labelText: 'Title'),
onChanged: (value) => title = value,
),
),
SizedBox(
height: 8,
),
RaisedButton(
onPressed: _setText,
child: Text('Submit'),
elevation: 8,
),
SizedBox(
height: 20,
),
Text(text),
// changes in text
// are shown here
],
),
);
}
}