Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter_web/material.dart';
- void main() => runApp(MyApp());
- class MyApp extends StatelessWidget {
- // This widget is the root of your application.
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- title: 'Flutter Demo',
- theme: ThemeData(
- primarySwatch: Colors.blue,
- ),
- home: MyHomePage(title: 'Flutter Demo Home Page'),
- );
- }
- }
- class MyHomePage extends StatelessWidget {
- MyHomePage({Key key, this.title}) : super(key: key);
- final String title;
- final _formKey = new GlobalKey<FormState>();
- @override
- Widget build(BuildContext context) {
- // The Flutter framework has been optimized to make rerunning build methods
- // fast, so that you can just rebuild anything that needs updating rather
- // than having to individually change instances of widgets.
- final email = Form(
- key: _formKey,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: <Widget>[
- SizedBox(height: 150.0,),
- //input field for email
- TextFormField(
- decoration: InputDecoration(labelText: 'Email'),
- validator: (value) => value.isEmpty ? 'Email cannot be blank':null,
- // onSaved: (value) => _email = value,
- ),
- //input field for password
- TextFormField(
- decoration: InputDecoration(labelText: 'Password'),
- obscureText: true,
- validator: (value) => value.isEmpty ? 'Password cannot be blank':null,
- // onSaved: (value) => _password = value,
- ),
- ]
- )
- );
- return Scaffold(
- appBar: AppBar(
- title: Text(title),
- ),
- body: Center(
- // Center is a layout widget. It takes a single child and positions it
- // in the middle of the parent.
- child: Column(
- // Column is also layout widget. It takes a list of children and
- // arranges them vertically. By default, it sizes itself to fit its
- // children horizontally, and tries to be as tall as its parent.
- //
- // Invoke "debug painting" (choose the "Toggle Debug Paint" action
- // from the Flutter Inspector in Android Studio, or the "Toggle Debug
- // Paint" command in Visual Studio Code) to see the wireframe for each
- // widget.
- //
- // Column has various properties to control how it sizes itself and
- // how it positions its children. Here we use mainAxisAlignment to
- // center the children vertically; the main axis here is the vertical
- // axis because Columns are vertical (the cross axis would be
- // horizontal).
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Text(
- 'Hello, World!',
- ),
- email,
- ],
- ),
- ), // This trailing comma makes auto-formatting nicer for build methods.
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement