Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:praktikum_pertemuan_10/home_page.dart';
- class LoginPage extends StatefulWidget {
- @override
- State<LoginPage> createState() => _LoginPageState();
- }
- class _LoginPageState extends State<LoginPage> {
- String _email = "temp";
- String _password = "temp";
- String _errorMessage = "Email atau Password Salah";
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text("Login Page"),
- ),
- body: SingleChildScrollView(
- child: Column(children: [
- Center(
- child: Container(
- padding: EdgeInsets.only(top: 40),
- height: 190,
- width: 230,
- child: Image.asset('assets/img/powerrenjes.png'),
- ),
- ),
- Padding(
- padding: const EdgeInsets.all(8.0),
- child: TextField(
- decoration: InputDecoration(
- border: OutlineInputBorder(),
- labelText: 'Email',
- hintText: 'Masukkan Alamat Email',
- ),
- onChanged: (text) {
- _email = text;
- },
- ),
- ),
- Padding(
- padding: const EdgeInsets.all(8.0),
- child: TextField(
- obscureText: true,
- decoration: InputDecoration(
- border: OutlineInputBorder(),
- labelText: 'Password',
- hintText: 'Masukkan Passsword',
- ),
- onChanged: (text) {
- _password = text;
- },
- ),
- ),
- Padding(
- padding: const EdgeInsets.all(10),
- child: Text(
- _errorMessage,
- style: TextStyle(color: Colors.red),
- ),
- ),
- Container(
- height: 50,
- width: 250,
- decoration: BoxDecoration(
- color: Colors.blue, borderRadius: BorderRadius.circular(20)),
- child: TextButton(
- onPressed: () {
- setState(() {
- if (_email == "anjay" && _password == "anjay") {
- _errorMessage = "";
- Navigator.pushReplacement(context,
- MaterialPageRoute(builder: (context) => HomePage()));
- } else {
- _errorMessage =
- "Email dan Password yang anda masukkan salah!!!";
- }
- });
- },
- child: Text(
- "Login",
- style: TextStyle(color: Colors.white, fontSize: 20),
- ),
- ),
- )
- ]),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement