sgsg
unknown
dart
4 years ago
1.6 kB
4
Indexable
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: Login(), ); } } class Login extends StatefulWidget { LoginState createState() => LoginState(); } class LoginState extends State<Login> { GlobalKey<ScaffoldState> scaffold = GlobalKey(); final _formKey = GlobalKey<FormState>(); @override Widget build(BuildContext context) { return Scaffold( key: scaffold, appBar: AppBar( title: Center( child: Text('Login Screen'), ), ), drawer: Drawer(), body: Form( key: _formKey, child: ListView(children: [ Container( alignment: Alignment.center, child: TextFormField( decoration: InputDecoration(labelText: 'Enter the Username'), )), Container( alignment: Alignment.center, child: TextFormField( validator: (value) { if (value == null) { return null; } if (value.length < 8) { return "Password length should be 8"; } }, decoration: InputDecoration(labelText: 'Enter the Password'), )), ]), )); } }
Editor is loading...