这是关于 googleSignIn 的错误:MissingPluginException(未在通道 plugins.flutter.io/google_sign_in 上找到方法 init 的实现)
here is the error about googleSignIn : MissingPluginException(No implementation found for method init on channel plugins.flutter.io/google_sign_in)
我在尝试继续 googleSignIn
时遇到错误
我到处搜索以找到解决方案,甚至 Whosebug 中的每个标题都已阅读并应用他们伤心的内容,但似乎无法解决
E/flutter (18732): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception:
MissingPluginException(No implementation found for method init on channel
plugins.flutter.io/google_sign_in)
E/flutter (18732): #0 MethodChannel._invokeMethod
(package:flutter/src/services/platform_channel.dart:156:7)
E/flutter (18732): <asynchronous suspension>
E/flutter (18732): #1 GoogleSignIn._callMethod
(package:google_sign_in/google_sign_in.dart:233:5)
E/flutter (18732): <asynchronous suspension>
E/flutter (18732): #2 GoogleSignIn.signIn.isCanceled
(package:google_sign_in/google_sign_in.dart)
E/flutter (18732): <asynchronous suspension>
E/flutter (18732):
提供代码如下
我想让它显示我在 initstate 中指定的静默条目的错误,我首先在那里得到错误,然后当我点击 google 登录按钮时,我得到错误我一开始就详细补充了,大家可以按照这里的代码来。
final GoogleSignIn googlegiris = GoogleSignIn();
final bool girdimi=false;
@override
void initState() {
googlegiris.onCurrentUserChanged.listen((googleHesap) {
setState(() {
kullaniciKontrol(googleHesap);
});
}, onError: (gHata) {
print("Hata Mesaj: " + gHata.toString());
});
googlegiris.signInSilently(suppressErrors: false).then((googleHesap2) {
setState(() {
kullaniciKontrol(googleHesap2);
});
}).catchError((gHata) {
print("Hata Mesaj 2: " + gHata.toString());
});
super.initState();
}
kullaniciGiris() {
setState(() {
googlegiris.signIn();
});
}
kullaniciKontrol(GoogleSignInAccount girisHesap) async {
if (girisHesap != null) {
await kullaniciFireStoreKayit();
setState(() {
girdimi = true;
});
} else {
setState(() {
girdimi = false;
});
}
}
kullaniciFireStoreKayit() async {
final GoogleSignInAccount gAnlikKullanici = googlegiris.currentUser;
DocumentSnapshot<Map<String, dynamic>> documentSnapshot = await kullaniciRef.doc(gAnlikKullanici.id).get();
if (!documentSnapshot.exists) {
final username = await Navigator.push(context, MaterialPageRoute(builder: (context) => HesapOlusturmaSayfasi()));
kullaniciRef.doc(gAnlikKullanici.id).set({
"id": gAnlikKullanici.id,
"profileName": gAnlikKullanici.displayName,
"username": username,
"url": gAnlikKullanici.photoUrl,
"email": gAnlikKullanici.email,
"biography": "",
"timestamp": timestamp,
});
await takipciRef.doc(anlikKullanici.id).collection("takipciler").doc(anlikKullanici.id).set({});
documentSnapshot = await kullaniciRef.doc(anlikKullanici.id).get();
}
anlikKullanici = Kullanici.fromDocument(documentSnapshot.data());
}
@override
Widget build(BuildContext context) {
if (girdimi == true) {
return GirisEkran();`enter code here`
} else {
return kayitEkrani();
}
}
如果您使用的是 google_sign_in 4.1.0
或更高版本,您应该可以上网,iOS 和 Android。
低于 4.1.0
的任何内容,您需要将 google_sign_in_web
添加到您的 pubspec.yaml.
这个异常是什么意思?
是Flutter Plugins应该使用的multiplatform-plugin概念的结果,叫做Federated plugins
,由多个子包组成:
- 一个接口,每个平台都必须实现
- app-package,提供flutter应用中应该使用的API
- 任何其他平台实现
当前平台用它的实现覆盖了当前的平台接口实例。
请阅读 official Flutter Federated Plugin Docs.
中的更多内容
在 google_sign_in 包的情况下,默认实现是移动应用程序通常使用的平台渠道实现。在网络上,使用 different implementation。
因此可能会出现平台通道异常,因为您在网络上试图 运行 它没有网络实现,或者在任何其他还没有平台实现的平台上(目前只有网络,iOS 和 Android 实现)。您可以检查 plugin page, right under the name: Sample image for the google_sign_in package.
是否支持某个平台
我自己解决了这个问题,我在 Android 集成中访问了这个网站 https://console.cloud.google.com/ and ı have enabled Google People API from there with my google account which ı created firestore with . I took this information from https://pub.dev/packages/google_sign_in。
我在尝试继续 googleSignIn
时遇到错误我到处搜索以找到解决方案,甚至 Whosebug 中的每个标题都已阅读并应用他们伤心的内容,但似乎无法解决
E/flutter (18732): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception:
MissingPluginException(No implementation found for method init on channel
plugins.flutter.io/google_sign_in)
E/flutter (18732): #0 MethodChannel._invokeMethod
(package:flutter/src/services/platform_channel.dart:156:7)
E/flutter (18732): <asynchronous suspension>
E/flutter (18732): #1 GoogleSignIn._callMethod
(package:google_sign_in/google_sign_in.dart:233:5)
E/flutter (18732): <asynchronous suspension>
E/flutter (18732): #2 GoogleSignIn.signIn.isCanceled
(package:google_sign_in/google_sign_in.dart)
E/flutter (18732): <asynchronous suspension>
E/flutter (18732):
提供代码如下
我想让它显示我在 initstate 中指定的静默条目的错误,我首先在那里得到错误,然后当我点击 google 登录按钮时,我得到错误我一开始就详细补充了,大家可以按照这里的代码来。
final GoogleSignIn googlegiris = GoogleSignIn();
final bool girdimi=false;
@override
void initState() {
googlegiris.onCurrentUserChanged.listen((googleHesap) {
setState(() {
kullaniciKontrol(googleHesap);
});
}, onError: (gHata) {
print("Hata Mesaj: " + gHata.toString());
});
googlegiris.signInSilently(suppressErrors: false).then((googleHesap2) {
setState(() {
kullaniciKontrol(googleHesap2);
});
}).catchError((gHata) {
print("Hata Mesaj 2: " + gHata.toString());
});
super.initState();
}
kullaniciGiris() {
setState(() {
googlegiris.signIn();
});
}
kullaniciKontrol(GoogleSignInAccount girisHesap) async {
if (girisHesap != null) {
await kullaniciFireStoreKayit();
setState(() {
girdimi = true;
});
} else {
setState(() {
girdimi = false;
});
}
}
kullaniciFireStoreKayit() async {
final GoogleSignInAccount gAnlikKullanici = googlegiris.currentUser;
DocumentSnapshot<Map<String, dynamic>> documentSnapshot = await kullaniciRef.doc(gAnlikKullanici.id).get();
if (!documentSnapshot.exists) {
final username = await Navigator.push(context, MaterialPageRoute(builder: (context) => HesapOlusturmaSayfasi()));
kullaniciRef.doc(gAnlikKullanici.id).set({
"id": gAnlikKullanici.id,
"profileName": gAnlikKullanici.displayName,
"username": username,
"url": gAnlikKullanici.photoUrl,
"email": gAnlikKullanici.email,
"biography": "",
"timestamp": timestamp,
});
await takipciRef.doc(anlikKullanici.id).collection("takipciler").doc(anlikKullanici.id).set({});
documentSnapshot = await kullaniciRef.doc(anlikKullanici.id).get();
}
anlikKullanici = Kullanici.fromDocument(documentSnapshot.data());
}
@override
Widget build(BuildContext context) {
if (girdimi == true) {
return GirisEkran();`enter code here`
} else {
return kayitEkrani();
}
}
如果您使用的是 google_sign_in 4.1.0
或更高版本,您应该可以上网,iOS 和 Android。
低于 4.1.0
的任何内容,您需要将 google_sign_in_web
添加到您的 pubspec.yaml.
这个异常是什么意思?
是Flutter Plugins应该使用的multiplatform-plugin概念的结果,叫做Federated plugins
,由多个子包组成:
- 一个接口,每个平台都必须实现
- app-package,提供flutter应用中应该使用的API
- 任何其他平台实现
当前平台用它的实现覆盖了当前的平台接口实例。 请阅读 official Flutter Federated Plugin Docs.
中的更多内容在 google_sign_in 包的情况下,默认实现是移动应用程序通常使用的平台渠道实现。在网络上,使用 different implementation。
因此可能会出现平台通道异常,因为您在网络上试图 运行 它没有网络实现,或者在任何其他还没有平台实现的平台上(目前只有网络,iOS 和 Android 实现)。您可以检查 plugin page, right under the name: Sample image for the google_sign_in package.
是否支持某个平台我自己解决了这个问题,我在 Android 集成中访问了这个网站 https://console.cloud.google.com/ and ı have enabled Google People API from there with my google account which ı created firestore with . I took this information from https://pub.dev/packages/google_sign_in。