Last active
April 12, 2022 03:26
-
-
Save triyono777/913bfee380e20c34525cf1eff25e8fcd to your computer and use it in GitHub Desktop.
This file contains hidden or 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'; | |
class LoginScreen extends StatefulWidget { | |
const LoginScreen({Key? key}) : super(key: key); | |
@override | |
State<LoginScreen> createState() => _LoginScreenState(); | |
} | |
class _LoginScreenState extends State<LoginScreen> { | |
TextEditingController userNameController = TextEditingController(); | |
TextEditingController passwordController = TextEditingController(); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: Column( | |
children: [ | |
Text( | |
'Login ', | |
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 30), | |
), | |
Image.asset('images/note_book.png'), | |
Padding( | |
padding: const EdgeInsets.symmetric(horizontal: 50, vertical: 10), | |
child: TextFormField( | |
controller: userNameController, | |
decoration: InputDecoration( | |
label: Text('Username'), | |
hintText: 'Masukkan username', | |
border: OutlineInputBorder( | |
borderRadius: BorderRadius.circular(30), | |
), | |
), | |
), | |
), | |
Padding( | |
padding: const EdgeInsets.symmetric(horizontal: 50, vertical: 10), | |
child: TextFormField( | |
controller: passwordController, | |
obscureText: true, | |
decoration: InputDecoration( | |
label: Text('Password'), | |
hintText: 'Masukkan password', | |
border: OutlineInputBorder( | |
borderRadius: BorderRadius.circular(30), | |
), | |
), | |
), | |
), | |
SizedBox( | |
width: 200, | |
height: 50, | |
child: ElevatedButton( | |
onPressed: () { | |
print('username = ${userNameController.text} '); | |
if(userNameController.text=='budi' && passwordController.text == '123' ){ | |
ScaffoldMessenger.of(context).showSnackBar( | |
SnackBar( | |
content: Text('anda berhasil login'), | |
), | |
); | |
}else{ | |
ScaffoldMessenger.of(context).showSnackBar( | |
SnackBar( | |
content: Text('username atau password salah'), | |
), | |
); | |
} | |
}, | |
style: ElevatedButton.styleFrom( | |
shape: RoundedRectangleBorder( | |
borderRadius: BorderRadius.circular(30), | |
), | |
), | |
child: Text('Login'), | |
), | |
), | |
SizedBox( | |
height: 20, | |
), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment