I wrote a function to login through google in my flutter app using firebase. But when I try to run my app I get the below error.I'm currently running flutter v2.5.3 but I upgraded it to v10... but still it didnt work
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-6.2.0/lib/src/method_channel/utils/exception.dart:14:11: Error: Method not found: 'Error.throwWithStackTrace'.
Error.throwWithStackTrace(exception, stackTrace);
^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/flutter/.pub-
cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-
6.2.0/lib/src/method_channel/utils/exception.dart:17:9: Error: Method not found:
'Error.throwWithStackTrace'.
Error.throwWithStackTrace(
^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/flutter/.pub-
cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-
6.2.0/lib/src/method_channel/utils/exception.dart:12:7: Error: A non-null value must be
returned since the return type 'Never' doesn't allow null.
Never convertPlatformException(Object exception, StackTrace stackTrace) {
^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1005
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\flutter\bin\flutter.bat'' finished with non-zero exit
value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 10s
Exception: Gradle task assembleDebug failed with exit code 1
Below is my function file
class GoogleSignInProvider extends ChangeNotifier{
final googleSignIn=GoogleSignIn();
GoogleSignInAccount?_user;
GoogleSignInAccount? get user=>_user!;
Future googleLogin() async{
final googleUser=await googleSignIn.signIn();
if(googleUser != null) return _user=googleUser;
final googleAuth = await googleUser!.authentication;
final credential = GoogleAuthProvider.credential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
await FirebaseAuth.instance.signInWithCredential(credential);
notifyListeners();
}
}
Please help!!!
Try upgrading flutter version to 2.10.3. The Error will be gone.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.