0

This is my error

I/flutter ( 8668): error while loging user PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) V/PhoneWindow( 8668): DecorView setVisiblity: visibility = 4, Parent = android.view.ViewRootImpl@d28de04, this = DecorView@a6ed458[SignInHubActivity] W/1.raster( 8668): type=1400 audit(0.0:699692): avc: denied { search } for name="battery" dev="sysfs" ino=6709 scontext=u:r:untrusted_app:s0:c190,c256,c512,c768 tcontext=u:object_r:sysfs_batteryinfo:s0 tclass=dir permissive=0 D/Surface ( 8668): Surface::disconnect(this=0x75b12b7000,api=1) D/View ( 8668): [Warning] assignParent to null: this = DecorView@a6ed458[SignInHubActivity]

This is my Code

import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:kitoob_app/view/diary/diary.dart';
import 'package:social_login_buttons/social_login_buttons.dart';
// import '../../data/auth.dart';

final _auth = FirebaseAuth.instance;

class Login extends StatefulWidget {
  const Login({Key? key}) : super(key: key);

  @override
  State<Login> createState() => _LoginState();
}

class _LoginState extends State<Login> {

  bool isUser = false;
  String? userName;

  Future<UserCredential> signInWithGoogle() async {
    // Trigger the authentication flow
    final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();

    // Obtain the auth details from the request
    final GoogleSignInAuthentication? googleAuth = await googleUser?.authentication;

    // Create a new credential
    final credential = GoogleAuthProvider.credential(
      accessToken: googleAuth?.accessToken,
      idToken: googleAuth?.idToken,
    );


    if(googleUser != null){
      isUser = true;
      // userName =  _auth.currentUser!.displayName;
    }
    return await FirebaseAuth.instance.signInWithCredential(credential);
  }
  @override

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 30.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: <Widget>[
            Column(
              children: <Widget>[
                Image.asset('images/kitoobSplash.jpeg',width: 190,),
              ],
            ),
            Column(
              children: <Widget>[
              SocialLoginButton(
                   buttonType: SocialLoginButtonType.google,
                   onPressed: () async {
                     try {
                       await signInWithGoogle();
                       isUser == true
                           ? Navigator.push(context,
                           MaterialPageRoute(builder: (context) => Dairy()))
                           : print('user not found');
                     }on FirebaseAuthException catch (e){
                       print('error while loging user FirebaseAuthException  ${e.message}');
                     }catch(e){
                       print('error while loging user $e');
                     }
                   },),
                const SizedBox(
                  height: 30.0,
                ),
                // SocialLoginButton(
                //   buttonType: SocialLoginButtonType.facebook,
                //   onPressed: () {
                //
                //   },
                // ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}```

0 Answers0