Advertisement
Nurrohman_rex

Untitled

Dec 24th, 2022
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.43 KB | None | 0 0
  1. import 'dart:async';
  2.  
  3. import 'package:flutter/cupertino.dart';
  4. import 'package:flutter/material.dart';
  5.  
  6. void main() => runApp(MyApp());
  7.  
  8. class MyApp extends StatelessWidget {
  9. // This widget is the root of your application.
  10. @override
  11. Widget build(BuildContext context) {
  12. return MaterialApp(
  13. // Application name
  14. debugShowCheckedModeBanner: false,
  15. home: LoginDemo(),
  16. );
  17. }
  18. }
  19.  
  20. class LoginDemo extends StatefulWidget {
  21. @override
  22. _LoginDemoState createState() => _LoginDemoState();
  23. }
  24.  
  25. class _LoginDemoState extends State<LoginDemo> {
  26. TextEditingController etEmail = new TextEditingController();
  27. TextEditingController etPassword = new TextEditingController();
  28.  
  29. @override
  30. Widget build(BuildContext context) {
  31. return Scaffold(
  32. appBar: AppBar(
  33. title: Text("Halaman Login"),
  34. ),
  35. body: SingleChildScrollView(
  36. child: Column(
  37. children: <Widget>[
  38. Padding(
  39. padding: const EdgeInsets.only(top: 60.0),
  40. child: Center(
  41. child: Container(
  42. width: 200,
  43. height: 150,
  44. child: Image.asset('images/flutter-logo.png')),
  45. ),
  46. ),
  47. Padding(
  48. padding: const EdgeInsets.symmetric(horizontal: 15),
  49. child: TextField(
  50. controller: etEmail,
  51. decoration: const InputDecoration(
  52. border: OutlineInputBorder(),
  53. labelText: 'Email',
  54. hintText: 'Masukkan E-Mail Anda'),
  55. ),
  56. ),
  57. Padding(
  58. padding: EdgeInsets.only(
  59. left: 15.0, right: 15.0, top: 15.0, bottom: 0),
  60. child: TextField(
  61. controller: etPassword,
  62. obscureText: true,
  63. decoration: const InputDecoration(
  64. border: OutlineInputBorder(),
  65. labelText: 'Password',
  66. hintText: 'Masukkan Password Anda'),
  67. ),
  68. ),
  69. TextButton(
  70. onPressed: () {
  71. //Todo List
  72. },
  73. child: Text(
  74. 'Lupa Password',
  75. style: TextStyle(color: Colors.blue, fontSize: 15),
  76. ),
  77. ),
  78. Container(
  79. height: 50,
  80. width: 250,
  81. decoration: BoxDecoration(
  82. color: Colors.blue, borderRadius: BorderRadius.circular(20)),
  83. child: TextButton(
  84. onPressed: () {
  85. setState(() {
  86. String Email = etEmail.text;
  87. String Password = etPassword.text;
  88. Navigator.push(
  89. context,
  90. MaterialPageRoute(
  91. builder: (context) => new ProfileDemo(
  92. email: Email, password: Password)));
  93. });
  94. },
  95. child: Text(
  96. 'Masuk',
  97. style: TextStyle(color: Colors.white, fontSize: 25),
  98. ),
  99. ),
  100. ),
  101. SizedBox(
  102. height: 130,
  103. ),
  104. Text('User Baru? Daftar Sekarang!')
  105. ],
  106. ),
  107. ),
  108. );
  109. }
  110. }
  111.  
  112. class ProfileDemo extends StatefulWidget {
  113. const ProfileDemo({key, required this.email, required this.password})
  114. : super(key: key);
  115.  
  116. final String email;
  117. final String password;
  118.  
  119. @override
  120. State<ProfileDemo> createState() => _ProfileDemoState();
  121. }
  122.  
  123. class _ProfileDemoState extends State<ProfileDemo> {
  124. TextEditingController emailController = TextEditingController();
  125. TextEditingController passwordController = TextEditingController();
  126. @override
  127. void initState() {
  128. setState(() {
  129. emailController.text = widget.email;
  130. passwordController.text = widget.password;
  131. });
  132. super.initState();
  133. }
  134.  
  135. @override
  136. Widget build(BuildContext context) {
  137. return Scaffold(
  138. appBar: AppBar(
  139. title: Text("Selamat Datang"),
  140. ),
  141. body: SingleChildScrollView(
  142. child: Column(
  143. children: <Widget>[
  144. Padding(
  145. padding: EdgeInsets.symmetric(horizontal: 15),
  146. child: TextField(
  147. controller: emailController,
  148. decoration: InputDecoration(
  149. border: OutlineInputBorder(),
  150. ),
  151. ),
  152. ),
  153. Padding(
  154. padding: EdgeInsets.symmetric(horizontal: 15),
  155. child: TextField(
  156. controller: passwordController,
  157. decoration: InputDecoration(
  158. border: OutlineInputBorder(),
  159. ),
  160. ),
  161. ),
  162. Container(
  163. height: 50,
  164. width: 250,
  165. decoration: BoxDecoration(
  166. color: Colors.blue, borderRadius: BorderRadius.circular(20)),
  167. child: TextButton(
  168. onPressed: () {
  169. Navigator.pop(context);
  170. },
  171. child: Text(
  172. 'Kembali',
  173. style: TextStyle(color: Colors.white, fontSize: 25),
  174. ),
  175. ),
  176. ),
  177. ],
  178. ),
  179. ),
  180. );
  181. }
  182. }
  183.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement