android Flutter Sign In Screen,Sign in with Google显示“发生未知错误”

wr98u20j  于 2023-06-04  发布在  Android
关注(0)|答案(1)|浏览(356)

升级到Flutter 3.10后,我使用Flutter Sign In Screen构建了我的Android应用程序。当我点击“使用Google登录”按钮时,会显示一个对话框,让我选择我的Google帐户。选择后,登录屏幕显示发生未知错误。我甚至升级了软件包,但没有改变。

下面是main.dart的一部分:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );

  /// The app uses Email and GoogleProvider to sign in.
  FirebaseUIAuth.configureProviders([
    EmailAuthProvider(),
    GoogleProvider(
        clientId:
            'CLIENT ID IS HERE'),
    // ... other providers can be added here if necessary
  ]);

  /// This prevents the app from rotating to landscape mode.
  SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
      .then((_) {
    runApp(EasyDynamicThemeWidget(child: const MyApp()));
  });
}

这是我的auth_gate.dart的一部分:

class _AuthGateState extends State<AuthGate> {
  @override
  Widget build(BuildContext context) {
    return StreamBuilder<User?>(
      stream: FirebaseAuth.instance.authStateChanges(),
      builder: (context, snapshot) {
        if (!snapshot.hasData) {
          return SignInScreen(
            headerBuilder: (context, constraints, _) {
              return Image.asset("assets/qaizenlogo.png");
            },
            footerBuilder: (context, action) {
              return Padding(
                  padding: const EdgeInsets.only(top: 40.0),
                  child: Text.rich(TextSpan(text: 'Need help? ', children: [
                    TextSpan(
                        text: 'Call Us',
                        style: const TextStyle(
                          //color: Theme.of(context).primaryColor,
                          color: Colors.deepPurple,
                          fontSize: 16,
                          decoration: TextDecoration.underline,
                          fontStyle: FontStyle.italic,
                          fontWeight: FontWeight.bold,
                        ),
                        recognizer: TapGestureRecognizer()
                          ..onTap = () {
                            showDialog(
                                context: context,
                                builder: (ctx) => AlertDialog(
                                      icon: const Icon(
                                        Icons.phone_outlined,
                                        color: Colors.blue,
                                      ),
                                      title: const Text("Call Us"),
                                      content: const Text(
                                        "We're here to help with any questions or concerns you may have. Do you want to proceed with the call?",
                                        style: TextStyle(fontSize: 18),
                                      ),
                                      actions: <Widget>[
                                        TextButton(
                                          onPressed: () async {
                                            Navigator.of(ctx).pop();
                                            //call
                                            //when call permission is granted:
                                            await FlutterPhoneDirectCaller
                                                .callNumber('PHONE NUMBER GOES HERE');
                                            //else not granted, just show phone number
                                            if (await Permission
                                                .phone.isDenied) {
                                              makePhoneCall();
                                            }
                                          },
                                          child: Text(
                                            "Yes",
                                            style: TextStyle(
                                                fontSize: 16,
                                                color: Theme.of(context)
                                                    .primaryColor),
                                          ),
                                        ),
                                        TextButton(
                                          onPressed: () =>
                                              Navigator.of(ctx).pop(),
                                          child: Text(
                                            "No",
                                            style: TextStyle(
                                                fontSize: 17,
                                                color: Theme.of(context)
                                                    .primaryColor),
                                          ),
                                        ),
                                      ],
                                    ));
                          })
                  ])));
            },
          );
        }
        return const HomeScreen();
      },
    );
  }
}

kgsdhlau

kgsdhlau1#

我找到了我的应用程序没有登录Google的原因。我没有将Google Play的应用签名密钥证书添加到Firebase。
Google Play控制台> [MyApp] >设置>应用完整性>应用签名

相关问题