Giter Club home page Giter Club logo

coding-with-flutter-login-demo's People

Contributors

bizz84 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coding-with-flutter-login-demo's Issues

Userid

Hi how can I get user ID with AouthProvider.of(context).aouth.surentUser();

I want to get user ID as setting in different page

Thank you love your work

auth.dart and login.dart error

when i cloned the project and run so error comes in auth.dart and in login page . how can i fix this.

error in auth.dart is "A value of type 'AuthResult' can't be assigned to a variable of type 'FirebaseUser'.
code is given below

class Auth implements BaseAuth {
final FirebaseAuth _firebaseAuth = FirebaseAuth.instance;

Future signIn(String email, String password) async {
FirebaseUser user = await _firebaseAuth.signInWithEmailAndPassword(email: email, password: password);
return user.uid;
}
Future createUser(String email, String password) async {
FirebaseUser user = await _firebaseAuth.createUserWithEmailAndPassword(email: email, password: password);
return user.uid;
}

and error in login The method 'signInWithEmailAndPassword' isn't defined for the class 'BaseAuth'.
code is given below

Future validateAndSubmit() async {
if (validateAndSave()) {
try {
final BaseAuth auth = AuthProvider.of(context).auth;
if (_formType == FormType.login) {
final String userId = await auth.signInWithEmailAndPassword(_email, _password);
print('Signed in: $userId');
} else {
final String userId = await auth.createUserWithEmailAndPassword(_email, _password);
print('Registered user: $userId');
}
widget.onSignedIn();
} catch (e) {
print('Error: $e');
}
}
}

Flutter firebase_auth errors

I'm fumbling with my loginPage.dart. I upgraded the pre- 1.12 project.
This seems to be the last part of the migration

I made the errors bold within the code block

The Errors are:
‘User’ isn’t a function
Try correcting the name to match an existing function, or define a method or function named ‘User’

Error:
The getter ‘did’, isn’t defined for the type ‘UserCredential’
Try importing the library that defines ‘did’, correcting the name from all but one of the imports

Error:
User’ isn’t a function
Try correcting the name to match an existing function, or define a method or function named ‘User’

Hopefully some one can help me out?

Looking forward hearing from you!
Kind regards,
Robert

From firebase_core: ^0.4.0+1 to firebase_core: ^0.5.0
From firebase_auth: ^0.11.1+3 to firebase_auth: ^0.18.0+1
From cloud_firestore: ^0.12.7+1 to cloud_firestore: ^0.14.0+2
From firebase_storage: ^3.0.4 to firebase_storage: ^4.0.0

 import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';

import '../Models/appConstants.dart';
import '../Models/userObjects.dart';
import './guestHomePage.dart';
import './signUpPage.dart';

class LoginPage extends StatefulWidget {
  static final String routeName = '/loginPageRoute';

  LoginPage({Key key}) : super(key: key);

  @override
  _LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  final _formKey = GlobalKey<FormState>();
  TextEditingController _emailController = TextEditingController();
  TextEditingController _passwordController = TextEditingController();

  void _signUp() {
    if (_formKey.currentState.validate()) {
      String email = _emailController.text;
      String password = _passwordController.text;
      **AppConstants.currentUser = User();**
      AppConstants.currentUser.email = email;
      AppConstants.currentUser.password = password;
      Navigator.pushNamed(context, SignUpPage.routeName);
    }
  }

  void _login() {
    if (_formKey.currentState.validate()) {
      String email = _emailController.text;
      String password = _passwordController.text;
      FirebaseAuth.instance
          .signInWithEmailAndPassword(
        email: email,
        password: password,
      )
          .then((firebaseUser) {
        **String userID = firebaseUser.uid;**
        **AppConstants.currentUser = User(id: userID);**
        AppConstants.currentUser
            .getPersonalInfoFromFirestore()
            .whenComplete(() {
          Navigator.pushNamed(context, GuestHomePage.routeName);
        });
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        child: Center(
          child: Padding(
            padding: const EdgeInsets.fromLTRB(50, 100, 50, 0),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              children: <Widget>[
                Text(
                  'Welcome to ${AppConstants.appName}!',
                  style: TextStyle(
                    fontWeight: FontWeight.bold,
                    fontSize: 30.0,
                  ),
                  textAlign: TextAlign.center,
                ),
                Form(
                  key: _formKey,
                  child: Column(
                    children: <Widget>[
                      Padding(
                        padding: const EdgeInsets.only(top: 35.0),
                        child: TextFormField(
                          decoration: InputDecoration(labelText: 'Email'),
                          style: TextStyle(
                            fontSize: 25.0,
                          ),
                          validator: (text) {
                            if (!text.contains('@')) {
                              return 'Please enter a valid email';
                            }
                            return null;
                          },
                          controller: _emailController,
                        ),
                      ),
                      Padding(
                        padding: const EdgeInsets.only(top: 25.0),
                        child: TextFormField(
                          decoration: InputDecoration(labelText: 'Password'),
                          style: TextStyle(
                            fontSize: 25.0,
                          ),
                          obscureText: true,
                          validator: (text) {
                            if (text.length < 6) {
                              return 'Password must be at least 6 characters';
                            }
                            return null;
                          },
                          controller: _passwordController,
                        ),
                      )
                    ],
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.only(top: 30.0),
                  child: MaterialButton(
                    onPressed: () {
                      _login();
                    },
                    child: Text(
                      'Login',
                      style: TextStyle(
                        fontWeight: FontWeight.bold,
                        fontSize: 25.0,
                      ),
                    ),
                    color: Colors.blue,
                    height: MediaQuery.of(context).size.height / 12,
                    minWidth: double.infinity,
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(10),
                    ),
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.only(top: 30.0),
                  child: MaterialButton(
                    onPressed: () {
                      _signUp();
                    },
                    child: Text(
                      'Sign Up',
                      style: TextStyle(
                        fontWeight: FontWeight.bold,
                        fontSize: 25.0,
                      ),
                    ),
                    color: Colors.grey,
                    height: MediaQuery.of(context).size.height / 12,
                    minWidth: double.infinity,
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(10),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

Casting issue

compiler message: lib/root_page.dart:57:24: Error: A value of type '#lib1::BaseAuth' can't be assigned to a variable of type '#lib2::BaseAuth'.
compiler message: Try changing the type of the left hand side, or casting the right hand side to '#lib2::BaseAuth'.
compiler message: auth: widget.auth,
compiler message: ^
Compiler failed on C:\Users\Dell-pc\AndroidStudioProjects\login_app\lib\main.dart

FAILURE: Build failed with an exception.

When upgrading to latest Auth

Greetings,

The latest auth package is 0.14.0+5.

This is required as some of the newer packages like storage is 3.0.6 requires a newer auth.

When you upgrade to that version of the auth package, the lines no longer work.


 Future<String> signInWithEmailAndPassword(String email, String password) async {
    final FirebaseUser user = await _firebaseAuth.signInWithEmailAndPassword(email: email, password: password);
 
    return user?.uid;
  }

The _firebaseAuth.signIn... now returns a different type, of AuthResult.

So I changed the code to be, (as a guess)


 Future<String> signInWithEmailAndPassword(String email, String password) async {
    final AuthResult auth = await _firebaseAuth.signInWithEmailAndPassword(email: email, password: password);
    final FirebaseUser user = auth.user; 
    return user?.uid;
  }


My new update actually doesn't log on and gets an error of casting from Null.

Any ideas?

App crashing on launch

I've been trying to fix it but every time it fails to launch on the device.
Initializing gradle, Resolving Dependencies, Gradle build all works properly. It even get's installed but it does not launch. It just crashes. FYI I am using Android 7 Nougat in a Xiomi Redmi Note 4.
Please check if it is a device specific issue, or is it doing so in your's too.

sign in error

Hi
Thank you for the lesson its really helpful.
i keep getting this issue when i try to login.

Notifying auth state listeners.
D/FirebaseApp(21644): Notified 0 auth state listeners.
I/flutter (21644): Signed in: 5LL4lM0lOVScxfF5oSmTHmvxotW2
I/flutter (21644): Error: NoSuchMethodError: The method 'call' was called on null.
I/flutter (21644): Receiver: null
I/flutter (21644): Tried calling: call()

the authentication works fine as you can see it returns uid. but it doesnt re direct to the new page i created

onSignedOut

how can I use onSignedOut in drawer page overtime I try it if failed to go back to login page any help ^_^

Thanks

Logout from any page

This is not so much an issue, but more a question about the YouTube video that you posted on March 7, 2019 (i.e. Flutter & Firebase authentication with streams and StreamBuilder)

After completing the steps in the video, we can only logout from the HomePage! From the HomePage, if we Push or PushReplacement a new route, and try to logout from that new route, we are not redirected to the LoginPage.

How would you change your code to be able to logout from any page? I'm sure many people are wondering the same thing :)

Thanks a lot!

error when try to sign in

I/flutter (13499): No implementation found for method signInWithCredential on channel plugins.flutter.io/firebase_auth

Auth can't be assigned to a variable type of BaseAuth

I believe I have implemented your code and have even gone as far as to copy and paste but I get the following error:

compiler message: lib/main.dart:14:13: Error: A value of type '#lib1::Auth' can't be assigned to a variable of type '#lib2::BaseAuth'.
compiler message: Try changing the type of the left hand side, or casting the right hand side to '#lib2::BaseAuth'.
compiler message:       auth: Auth(),
compiler message:             ^

google_sign_in: 3.0.4
firebase_auth: 0.5.18

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.