Last active
April 12, 2022 13:02
-
-
Save triyono777/4829c94c55811b982efe58e0bffa5436 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(); | |
bool hidePass = true; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
backgroundColor: Colors.white, | |
body: Column( | |
children: [ | |
SizedBox( | |
height: 20, | |
), | |
Text( | |
'Login', | |
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 30), | |
), | |
Expanded( | |
child: Image.asset( | |
'images/undraw_new_ideas_jdea.png', | |
height: 1000, | |
), | |
), | |
Padding( | |
padding: const EdgeInsets.symmetric(horizontal: 50, vertical: 10), | |
child: TextFormField( | |
controller: userNameController, | |
decoration: InputDecoration( | |
labelText: 'Username', | |
hintText: 'SIlakan masukkan username', | |
border: OutlineInputBorder( | |
borderRadius: BorderRadius.circular(30), | |
), | |
), | |
), | |
), | |
Padding( | |
padding: const EdgeInsets.symmetric(horizontal: 50, vertical: 10), | |
child: TextFormField( | |
obscureText: hidePass, | |
controller: passwordController, | |
decoration: InputDecoration( | |
suffixIcon: IconButton( | |
icon: Icon(hidePass? Icons.visibility :Icons.visibility_off ), | |
onPressed: (){ | |
setState(() { | |
hidePass = !hidePass; | |
}); | |
}, | |
), | |
labelText: 'Password', | |
hintText: 'SIlakan masukkan password', | |
border: OutlineInputBorder( | |
borderRadius: BorderRadius.circular(30), | |
), | |
), | |
), | |
), | |
SizedBox( | |
width: 300, | |
height: 50, | |
child: ElevatedButton( | |
onPressed: () { | |
if (userNameController.text == "budi" && | |
passwordController.text == "123") { | |
ScaffoldMessenger.of(context).showSnackBar( | |
SnackBar( | |
content: Text('Sukses login'), | |
), | |
); | |
} else { | |
ScaffoldMessenger.of(context).showSnackBar( | |
SnackBar( | |
content: Text('User name atau password salah'), | |
), | |
); | |
} | |
}, | |
style: ElevatedButton.styleFrom( | |
shape: RoundedRectangleBorder( | |
borderRadius: BorderRadius.circular(30), | |
), | |
), | |
child: Text('Sign In')), | |
), | |
GestureDetector( | |
onTap: (){ | |
ScaffoldMessenger.of(context).showSnackBar( | |
SnackBar( | |
content: Text('Halaman signup'), | |
), | |
); | |
}, | |
child: Text('Tidak punya akun? Sign up')), | |
SizedBox( | |
height: 20, | |
) | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment