【发布时间】:2021-07-30 22:19:11
【问题描述】:
所以我使用 Firebase 身份验证和实时数据库在颤动中制作了这个注册页面。身份验证工作正常,但我的数据库有问题,它只是没有被创建。在按照谷歌上的一些说明进行操作后,我也尝试使用 push(),但它没有帮助。 goggle 上没有足够的关于 firebase 实时数据库的说明。任何帮助将不胜感激!
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
DatabaseReference usersRef = FirebaseDatabase.instance.reference().child("users");
final FirebaseAuth _firebaseAuth = FirebaseAuth.instance;
void registerNewUser(BuildContext context) async {
final User firebaseUser = (await _firebaseAuth
.createUserWithEmailAndPassword(
email: emailTextEditingController.text,
password: passwordTextEditingController.text)
.catchError((errMsg) {
displayToastMessage("Error: " + errMsg.toString(), context);
}))
.user;
if (firebaseUser != null) {
Map userDataMap = {
"name": nameTextEditingController.text.trim(),
"email": emailTextEditingController.text.trim(),
"phone": phoneTextEditingController.text.trim(),
};
usersRef.child(firebaseUser.uid).set(userDataMap);
displayToastMessage("Account Created", context);
Navigator.pushNamedAndRemoveUntil(
context, MainScreen.idScreen, (route) => false);
//here
} else {
displayToastMessage("Account Not Created", context);
}
}
调试控制台
Launching lib/main.dart on M2003J15SC in debug mode...
lib/main.dart:1
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:46469/nnTIbYfPB8Q=/ws
I/GED (24582): ged_boost_gpu_freq, level 100, eOrigin 2, final_idx 31, oppidx_max 31, oppidx_min 0
I/deu.lagdeuride(24582): ProcessProfilingInfo new_methods=1227 is saved saved_to_disk=1 resolve_classes_delay=8000
W/IInputConnectionWrapper(24582): beginBatchEdit on inactive InputConnection
W/IInputConnectionWrapper(24582): getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper(24582): getTextAfterCursor on inactive InputConnection
W/IInputConnectionWrapper(24582): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper(24582): endBatchEdit on inactive InputConnection
W/IInputConnectionWrapper(24582): beginBatchEdit on inactive InputConnection
W/IInputConnectionWrapper(24582): endBatchEdit on inactive InputConnection
W/IInputConnectionWrapper(24582): beginBatchEdit on inactive InputConnection
W/IInputConnectionWrapper(24582): getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper(24582): getTextAfterCursor on inactive InputConnection
W/IInputConnectionWrapper(24582): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper(24582): endBatchEdit on inactive InputConnection
W/System (24582): Ignoring header X-Firebase-Locale because its value was null.
I/System.out(24582): [okhttp]:check permission begin!
W/System (24582): ClassLoader referenced unknown path: system/framework/mediatek-cta.jar
I/System.out(24582): [okhttp] e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaUtils
I/System.out(24582): [socket]:check permission begin!
W/System (24582): ClassLoader referenced unknown path: system/framework/mediatek-cta.jar
I/System.out(24582): [socket] e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaUtils
I/System.out(24582): [OkHttp] sendRequest<<
W/System (24582): Ignoring header X-Firebase-Locale because its value was null.
I/System.out(24582): [okhttp]:check permission begin!
W/System (24582): ClassLoader referenced unknown path: system/framework/mediatek-cta.jar
I/System.out(24582): [okhttp] e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaUtils
I/System.out(24582): [OkHttp] sendRequest<<
D/FirebaseAuth(24582): Notifying id token listeners about user ( hULpKuZcGNhVE45xcR5RkrlCPTl1 ).
D/FirebaseAuth(24582): Notifying auth state listeners about user ( hULpKuZcGNhVE45xcR5RkrlCPTl1 ).
D/ViewRootImpl[Toast](24582): hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false
I/Toast (24582): Show toast from OpPackageName:com.lagdeu.lagdeurider, PackageName:com.lagdeu.lagdeurider
D/Surface (24582): Surface::connect(this=0x77eefc2000,api=1)
D/mali_winsys(24582): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/Surface (24582): Surface::setBufferCount(this=0x77eefc2000,bufferCount=3)
D/Surface (24582): Surface::allocateBuffers(this=0x77eefc2000)
I/System.out(24582): [socket]:check permission begin!
W/System (24582): ClassLoader referenced unknown path: system/framework/mediatek-cta.jar
I/System.out(24582): [socket] e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaUtils
D/Surface (24582): Surface::disconnect(this=0x77eefc2000,api=1)
D/View (24582): [Warning] assignParent to null: this = android.widget.LinearLayout{7763522 V.E...... ......ID 0,0-564,316}
输出为空。
【问题讨论】:
-
很难将您共享的调试输出与您也共享的代码关联起来。当您在调试器中逐行执行代码时,在
usersRef.child(firebaseUser.uid).set(userDataMap);之后/之后会生成什么输出?
标签: firebase flutter firebase-realtime-database