Skip to content

Instantly share code, notes, and snippets.

@triyono777
Last active April 12, 2022 03:26
Show Gist options
  • Save triyono777/913bfee380e20c34525cf1eff25e8fcd to your computer and use it in GitHub Desktop.
Save triyono777/913bfee380e20c34525cf1eff25e8fcd to your computer and use it in GitHub Desktop.
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