Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'dart:async';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- void main() => runApp(MyApp());
- class MyApp extends StatelessWidget {
- // This widget is the root of your application.
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- // Application name
- debugShowCheckedModeBanner: false,
- home: LoginDemo(),
- );
- }
- }
- class LoginDemo extends StatefulWidget {
- @override
- _LoginDemoState createState() => _LoginDemoState();
- }
- class _LoginDemoState extends State<LoginDemo> {
- TextEditingController etEmail = new TextEditingController();
- TextEditingController etPassword = new TextEditingController();
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text("Halaman Login"),
- ),
- body: SingleChildScrollView(
- child: Column(
- children: <Widget>[
- Padding(
- padding: const EdgeInsets.only(top: 60.0),
- child: Center(
- child: Container(
- width: 200,
- height: 150,
- child: Image.asset('images/flutter-logo.png')),
- ),
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 15),
- child: TextField(
- controller: etEmail,
- decoration: const InputDecoration(
- border: OutlineInputBorder(),
- labelText: 'Email',
- hintText: 'Masukkan E-Mail Anda'),
- ),
- ),
- Padding(
- padding: EdgeInsets.only(
- left: 15.0, right: 15.0, top: 15.0, bottom: 0),
- child: TextField(
- controller: etPassword,
- obscureText: true,
- decoration: const InputDecoration(
- border: OutlineInputBorder(),
- labelText: 'Password',
- hintText: 'Masukkan Password Anda'),
- ),
- ),
- TextButton(
- onPressed: () {
- //Todo List
- },
- child: Text(
- 'Lupa Password',
- style: TextStyle(color: Colors.blue, fontSize: 15),
- ),
- ),
- Container(
- height: 50,
- width: 250,
- decoration: BoxDecoration(
- color: Colors.blue, borderRadius: BorderRadius.circular(20)),
- child: TextButton(
- onPressed: () {
- setState(() {
- String Email = etEmail.text;
- String Password = etPassword.text;
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => new ProfileDemo(
- email: Email, password: Password)));
- });
- },
- child: Text(
- 'Masuk',
- style: TextStyle(color: Colors.white, fontSize: 25),
- ),
- ),
- ),
- SizedBox(
- height: 130,
- ),
- Text('User Baru? Daftar Sekarang!')
- ],
- ),
- ),
- );
- }
- }
- class ProfileDemo extends StatefulWidget {
- const ProfileDemo({key, required this.email, required this.password})
- : super(key: key);
- final String email;
- final String password;
- @override
- State<ProfileDemo> createState() => _ProfileDemoState();
- }
- class _ProfileDemoState extends State<ProfileDemo> {
- TextEditingController emailController = TextEditingController();
- TextEditingController passwordController = TextEditingController();
- @override
- void initState() {
- setState(() {
- emailController.text = widget.email;
- passwordController.text = widget.password;
- });
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text("Selamat Datang"),
- ),
- body: SingleChildScrollView(
- child: Column(
- children: <Widget>[
- Padding(
- padding: EdgeInsets.symmetric(horizontal: 15),
- child: TextField(
- controller: emailController,
- decoration: InputDecoration(
- border: OutlineInputBorder(),
- ),
- ),
- ),
- Padding(
- padding: EdgeInsets.symmetric(horizontal: 15),
- child: TextField(
- controller: passwordController,
- decoration: InputDecoration(
- border: OutlineInputBorder(),
- ),
- ),
- ),
- Container(
- height: 50,
- width: 250,
- decoration: BoxDecoration(
- color: Colors.blue, borderRadius: BorderRadius.circular(20)),
- child: TextButton(
- onPressed: () {
- Navigator.pop(context);
- },
- child: Text(
- 'Kembali',
- style: TextStyle(color: Colors.white, fontSize: 25),
- ),
- ),
- ),
- ],
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement