Last active
July 7, 2020 17:50
-
-
Save dhruvilp/31a9d79b80528bc23790888403ff6ab7 to your computer and use it in GitHub Desktop.
Flutter Form Fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter/cupertino.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Text Fields', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: MyHomePage(), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
MyHomePage({Key key}) : super(key: key); | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
backgroundColor: Colors.white, | |
body: Column( | |
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | |
crossAxisAlignment: CrossAxisAlignment.center, | |
children: <Widget>[ | |
Center( | |
child: Container( | |
width: 300.0, | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
Padding( | |
padding: const EdgeInsets.symmetric( | |
vertical: 5.0, | |
horizontal: 2.0, | |
), | |
child: Text('Email Address', | |
style: TextStyle( | |
color: Colors.grey, | |
)), | |
), | |
CupertinoTextField( | |
// placeholder: 'Email', | |
keyboardType: TextInputType.emailAddress, | |
clearButtonMode: OverlayVisibilityMode.editing, | |
padding: EdgeInsets.all(15.0), | |
decoration: BoxDecoration( | |
color: Colors.grey.shade100, | |
borderRadius: BorderRadius.circular(8.0), | |
), | |
), | |
], | |
), | |
), | |
), | |
Center( | |
child: Container( | |
width: 300.0, | |
child: TextFormField( | |
keyboardType: TextInputType.emailAddress, | |
decoration: InputDecoration( | |
labelText: 'Email', | |
hintText: 'Enter email address', | |
fillColor: Colors.grey.shade100, | |
isDense: true, | |
filled: true, | |
floatingLabelBehavior: FloatingLabelBehavior.never, | |
border: OutlineInputBorder( | |
borderSide: | |
BorderSide(color: Colors.grey.shade100, width: 1.0), | |
borderRadius: BorderRadius.all(Radius.circular(8.0)), | |
), | |
), | |
), | |
), | |
), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment