blob: 808bc15e00c2041899f3f1e306eb6f16367542ef [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
/// Credential data class.
class Credentials {
/// Creates a credential data object.
Credentials(this.username, this.password);
/// The username of the credentials.
final String username;
/// The password of the credentials.
final String password;
/// The sign-in screen.
class SignInScreen extends StatefulWidget {
/// Creates a sign-in screen.
const SignInScreen({
required this.onSignIn,
Key? key,
}) : super(key: key);
/// Called when users sign in with [Credentials].
final ValueChanged<Credentials> onSignIn;
_SignInScreenState createState() => _SignInScreenState();
class _SignInScreenState extends State<SignInScreen> {
final TextEditingController _usernameController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
Widget build(BuildContext context) => Scaffold(
body: Center(
child: Card(
child: Container(
constraints: BoxConstraints.loose(const Size(600, 600)),
padding: const EdgeInsets.all(8),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text('Sign in', style: Theme.of(context).textTheme.headline4),
decoration: const InputDecoration(labelText: 'Username'),
controller: _usernameController,
decoration: const InputDecoration(labelText: 'Password'),
obscureText: true,
controller: _passwordController,
padding: const EdgeInsets.all(16),
child: TextButton(
onPressed: () async {
child: const Text('Sign in'),