Advertisement
Guest User

Flutter_web_input

a guest
Sep 15th, 2019
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 3.19 KB | None | 0 0
  1. import 'package:flutter_web/material.dart';
  2.  
  3. void main() => runApp(MyApp());
  4.  
  5. class MyApp extends StatelessWidget {
  6.   // This widget is the root of your application.
  7.   @override
  8.   Widget build(BuildContext context) {
  9.     return MaterialApp(
  10.       title: 'Flutter Demo',
  11.       theme: ThemeData(
  12.         primarySwatch: Colors.blue,
  13.       ),
  14.       home: MyHomePage(title: 'Flutter Demo Home Page'),
  15.     );
  16.   }
  17. }
  18.  
  19. class MyHomePage extends StatelessWidget {
  20.   MyHomePage({Key key, this.title}) : super(key: key);
  21.  
  22.   final String title;
  23. final _formKey = new GlobalKey<FormState>();
  24.   @override
  25.   Widget build(BuildContext context) {
  26.     // The Flutter framework has been optimized to make rerunning build methods
  27.     // fast, so that you can just rebuild anything that needs updating rather
  28.     // than having to individually change instances of widgets.
  29.     final email = Form(
  30.             key: _formKey,
  31.             child: Column(
  32.               crossAxisAlignment: CrossAxisAlignment.stretch,
  33.                 children: <Widget>[
  34.                   SizedBox(height: 150.0,),
  35.                   //input field for email
  36.                   TextFormField(
  37.                     decoration: InputDecoration(labelText: 'Email'),
  38.                     validator: (value) => value.isEmpty ? 'Email cannot be blank':null,
  39.                     //       onSaved: (value) => _email = value,
  40.                   ),
  41.                   //input field for password
  42.                   TextFormField(
  43.                     decoration: InputDecoration(labelText: 'Password'),
  44.                     obscureText: true,
  45.                     validator: (value) => value.isEmpty ? 'Password cannot be blank':null,
  46.                     //     onSaved: (value) => _password = value,
  47.                   ),
  48.                  
  49.                 ]
  50.             )
  51.     );
  52.  
  53.     return Scaffold(
  54.       appBar: AppBar(
  55.         title: Text(title),
  56.       ),
  57.       body: Center(
  58.         // Center is a layout widget. It takes a single child and positions it
  59.         // in the middle of the parent.
  60.         child: Column(
  61.           // Column is also layout widget. It takes a list of children and
  62.           // arranges them vertically. By default, it sizes itself to fit its
  63.           // children horizontally, and tries to be as tall as its parent.
  64.           //
  65.           // Invoke "debug painting" (choose the "Toggle Debug Paint" action
  66.           // from the Flutter Inspector in Android Studio, or the "Toggle Debug
  67.           // Paint" command in Visual Studio Code) to see the wireframe for each
  68.           // widget.
  69.           //
  70.           // Column has various properties to control how it sizes itself and
  71.           // how it positions its children. Here we use mainAxisAlignment to
  72.           // center the children vertically; the main axis here is the vertical
  73.           // axis because Columns are vertical (the cross axis would be
  74.           // horizontal).
  75.           mainAxisAlignment: MainAxisAlignment.center,
  76.           children: <Widget>[
  77.             Text(
  78.               'Hello, World!',
  79.             ),
  80.             email,
  81.           ],
  82.         ),
  83.       ), // This trailing comma makes auto-formatting nicer for build methods.
  84.     );
  85.   }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement