Advertisement
Guest User

Untitled

a guest
Aug 26th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_app_firebase_auth/auth.dart';
  3. import 'package:flutter_app_firebase_auth/home.dart';
  4.  
  5. class Login extends StatefulWidget {
  6. @override
  7. State<StatefulWidget> createState() => _LoginState();
  8. }
  9.  
  10. class _LoginState extends State<Login> {
  11. String email = "hung-nguyen@test.com";
  12. String pass = "123456";
  13.  
  14. @override
  15. Widget build(BuildContext context) {
  16. return Scaffold(
  17. backgroundColor: Colors.grey[300],
  18. appBar: AppBar(
  19. title: Text("Login"),
  20. automaticallyImplyLeading: false,
  21. ),
  22. body: Center(
  23. child: Column(
  24. children: <Widget>[
  25. FlatButton(
  26. onPressed: () {
  27. AppAuth()
  28. .signUpWithEmailAndPassword(email: email, password: pass)
  29. .then((authResult) {
  30. if (authResult.user != null) {
  31. Navigator.of(context)
  32. .push(MaterialPageRoute(builder: (context) => Home()));
  33. }
  34. });
  35. },
  36. child: Text("Sign up with email and password"),
  37. ),
  38. FlatButton(
  39. onPressed: () {
  40. AppAuth()
  41. .signInWithEmailAndPassword(email: email, password: pass)
  42. .then((authResult) {
  43. if (authResult.user != null) {
  44. Navigator.of(context)
  45. .push(MaterialPageRoute(builder: (context) => Home()));
  46. }
  47. });
  48. },
  49. child: Text("Log in with email and password"),
  50. ),
  51. FlatButton(
  52. onPressed: () {
  53. AppAuth().signInWithGoogle().then((authResult) {
  54. if (authResult.user != null) {
  55. Navigator.of(context).push(
  56. MaterialPageRoute(builder: (context) => Home()));
  57. }
  58. });
  59. },
  60. child: Text("Login with Google")),
  61. FlatButton(
  62. onPressed: () {
  63. AppAuth().signInWithFacebook().then((authResult) {
  64. if (authResult.user != null) {
  65. Navigator.of(context).push(
  66. MaterialPageRoute(builder: (context) => Home()));
  67. }
  68. });
  69. },
  70. child: Text("Login with Facebook")),
  71. ],
  72. ),
  73. ),
  74. );
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement