嗨,当我运行这个应用程序时,我正在开发一个颤振应用程序,这只会返回一个空白屏幕
这是具有 firebase 身份验证代码的 main.dart 文件的代码
***main.dart***
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:multi_purpose_scope/HomePage.dart';
import 'package:multi_purpose_scope/PatientList.dart';
import 'package:provider/provider.dart';
import 'AuthenticationService.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
Provider<AuthenticationService>(
create: (_) => AuthenticationService(FirebaseAuth.instance),
),
StreamProvider(
create: (context) => context.read<AuthenticationService>().authStateChanges,
)
],
child: MaterialApp(
home: AuthenticationWrapper(),
),
);
}
}
class AuthenticationWrapper extends StatelessWidget {
@override
Widget build(BuildContext context) {
final firebaseUser = context.watch<User>();
if (firebaseUser != null) {
return HomePage();
}
return PatientList();
}
}
***HomePage.dart***
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'Animation/FadeAnimation.dart';
import 'AuthenticationService.dart';
import 'ForgotPassword.dart';
import 'PatientList.dart';
class HomePage extends StatelessWidget {
final TextEditingController emailController = TextEditingController();
final TextEditingController passwordController = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Container(
child: Column(
children: <Widget>[
Container(
height: 400,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/loginHeader.png'),
fit: BoxFit.fill)),
child: Stack(
children: <Widget>[],
),
),
Padding(
padding: EdgeInsets.all(30.0),
child: Column(
children: <Widget>[
FadeAnimation(
1.8,
Container(
padding: EdgeInsets.all(5),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: Color.fromRGBO(143, 148, 251, .2),
blurRadius: 20.0,
offset: Offset(0, 10))
]),
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.all(8.0),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Colors.grey[100]))),
child: TextField(
controller: emailController,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Email or Phone number",
hintStyle:
TextStyle(color: Colors.grey[400])),
),
),
Container(
padding: EdgeInsets.all(8.0),
child: TextField(
controller: passwordController,
obscureText: true,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Password",
hintStyle:
TextStyle(color: Colors.grey[400])),
),
)
],
),
)),
SizedBox(
height: 30,
),
RaisedButton(
padding: EdgeInsets.only(
left: 100, right: 100, top: 20, bottom: 20),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(28.0),
side: BorderSide(color: Colors.red)),
onPressed: () {
gotoPatientList(BuildContext context) {
context.read<AuthenticationService>().signIn(
email: emailController.text.trim(),
password: passwordController.text.trim(),
);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PatientList()),
);
}
gotoPatientList(context);
},
color: Color.fromRGBO(214, 0, 27, 1),
textColor: Colors.white,
child: Text("Login".toUpperCase(),
style: TextStyle(fontSize: 14)),
),
Padding(
padding: EdgeInsets.only(top: 15),
),
ClipOval(
child: RaisedButton(
onPressed: () {
gotoForgotPassword(BuildContext context) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ForgotPassword()),
);
}
gotoForgotPassword(context);
},
child: Text("Forgot Password"),
textColor: Colors.white,
color: Color.fromRGBO(214, 0, 27, 1),
),
),
],
),
)
],
),
),
),
);
}
}
class AuthenticationWrapper extends StatelessWidget {
@override
Widget build(BuildContext context) {
final firebaseUser = context.watch<User>();
if (firebaseUser != null) {
return HomePage();
}
return PatientList();
}
}
这里是日志:
2021-02-16 18:19:30.953 21904-21904/? E/Zygote: isWhitelistProcess - Process is Whitelisted
2021-02-16 18:19:30.954 21904-21904/? E/libpersona: scanKnoxPersonas
2021-02-16 18:19:30.955 21904-21904/? E/libpersona: Couldn't open the File - /data/system/users/0/personalist.xml - No such file or directory
2021-02-16 18:19:30.958 21904-21904/? W/SELinux: SELinux selinux_android_compute_policy_index : Policy Index[2], Con:u:r:zygote:s0 RAM:SEPF_SM-G935T_8.0.0_0017, [-1 -1 -1 -1 0 1]
2021-02-16 18:19:30.959 21904-21904/? I/SELinux: SELinux: seapp_context_lookup: seinfo=untrusted, level=s0:c512,c768, pkgname=com.akdndhrc.multipurposescope
2021-02-16 18:19:30.968 21904-21904/? I/zygote64: Late-enabling -Xcheck:jni
2021-02-16 18:19:31.053 21904-21904/? D/TimaKeyStoreProvider: TimaKeyStore is not enabled: cannot add TimaSignature Service and generateKeyPair Service
2021-02-16 18:19:31.054 21904-21904/? D/ActivityThread: Added TimaKeyStore provider
2021-02-16 18:19:31.126 21904-21904/com.akdndhrc.multipurposescope I/zygote64: no shared libraies, dex_files: 1
2021-02-16 18:19:31.194 21904-21924/com.akdndhrc.multipurposescope W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2021-02-16 18:19:31.215 21904-21927/com.akdndhrc.multipurposescope W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2021-02-16 18:19:31.226 21904-21923/com.akdndhrc.multipurposescope W/zygote64: Skipping duplicate class check due to unrecognized classloader
2021-02-16 18:19:31.230 21904-21923/com.akdndhrc.multipurposescope I/DynamiteModule: Considering local module com.google.android.gms.measurement.dynamite:19 and remote module com.google.android.gms.measurement.dynamite:45
2021-02-16 18:19:31.231 21904-21923/com.akdndhrc.multipurposescope I/DynamiteModule: Selected remote version of com.google.android.gms.measurement.dynamite, version >= 45
2021-02-16 18:19:31.232 21904-21923/com.akdndhrc.multipurposescope V/DynamiteModule: Dynamite loader version >= 2, using loadModule2NoCrashUtils
2021-02-16 18:19:31.245 21904-21927/com.akdndhrc.multipurposescope I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
2021-02-16 18:19:31.245 21904-21904/com.akdndhrc.multipurposescope D/FirebaseAuth: Notifying id token listeners about user ( UvIJfW4TZZQM3nIETraMvnjAXdt2 ).
2021-02-16 18:19:31.252 21904-21904/com.akdndhrc.multipurposescope I/FirebaseInitProvider: FirebaseApp initialization successful
2021-02-16 18:19:31.260 21904-21923/com.akdndhrc.multipurposescope W/ResourceType: ResTable_typeSpec entry count inconsistent: given 67, previously 69
2021-02-16 18:19:31.260 21904-21923/com.akdndhrc.multipurposescope W/ResourceType: ResTable_typeSpec entry count inconsistent: given 5486, previously 5487
2021-02-16 18:19:31.263 21904-21904/com.akdndhrc.multipurposescope I/System.out: should load native is true
2021-02-16 18:19:31.265 21904-21904/com.akdndhrc.multipurposescope D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2021-02-16 18:19:31.277 21904-21932/com.akdndhrc.multipurposescope I/ResourceExtractor: Found extracted resources res_timestamp-1-1613478813305
2021-02-16 18:19:31.285 21904-21923/com.akdndhrc.multipurposescope I/DynamiteLoaderV2Impl: [71] Measurementdynamite
2021-02-16 18:19:31.295 21904-21923/com.akdndhrc.multipurposescope W/zygote64: Skipping duplicate class check due to unrecognized classloader
2021-02-16 18:19:31.342 21904-21904/com.akdndhrc.multipurposescope I/Adreno: QUALCOMM build : 1b7798b, I8a9bdcf8d3
Build Date : 03/15/18
OpenGL ES Shader Compiler Version: EV031.22.00.01
Local Branch :
Remote Branch : refs/tags/AU_LINUX_ANDROID_LA.UM.6.5.R1.08.00.00.312.043
Remote Branch : NONE
Reconstruct Branch : NOTHING
2021-02-16 18:19:31.344 21904-21904/com.akdndhrc.multipurposescope I/vndksupport: sphal namespace is not configured for this process. Loading /vendor/lib64/hw/gralloc.msm8996.so from the current namespace instead.
2021-02-16 18:19:31.350 21904-21904/com.akdndhrc.multipurposescope I/Adreno: PFP: 0x005ff087, ME: 0x005ff063
2021-02-16 18:19:31.468 21904-21943/com.akdndhrc.multipurposescope I/FA: App measurement initialized, version: 38002
2021-02-16 18:19:31.468 21904-21943/com.akdndhrc.multipurposescope I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
2021-02-16 18:19:31.470 21904-21943/com.akdndhrc.multipurposescope I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.akdndhrc.multipurposescope
2021-02-16 18:19:31.625 21904-21951/com.akdndhrc.multipurposescope D/OpenGLRenderer: HWUI GL Pipeline
2021-02-16 18:19:31.635 21904-21904/com.akdndhrc.multipurposescope D/ViewRootImpl@a1b73ed[MainActivity]: setView = DecorView@150c222[MainActivity] TM=true MM=false
2021-02-16 18:19:31.650 21904-21904/com.akdndhrc.multipurposescope V/InputMethodManager: Not IME target window, ignoring
2021-02-16 18:19:31.651 21904-21904/com.akdndhrc.multipurposescope D/ViewRootImpl@a1b73ed[MainActivity]: dispatchAttachedToWindow
2021-02-16 18:19:31.679 21904-21904/com.akdndhrc.multipurposescope V/Surface: sf_framedrop debug : 0x4f4c, game : false, logging : 0
2021-02-16 18:19:31.683 21904-21904/com.akdndhrc.multipurposescope D/ViewRootImpl@a1b73ed[MainActivity]: Relayout returned: old=[0,0][0,0] new=[0,0][1080,1920] result=0x7 surface={valid=true 483817242624} changed=true
2021-02-16 18:19:31.684 21904-21951/com.akdndhrc.multipurposescope I/OpenGLRenderer: Initialized EGL, version 1.4
2021-02-16 18:19:31.684 21904-21951/com.akdndhrc.multipurposescope D/OpenGLRenderer: Swap behavior 2
2021-02-16 18:19:31.698 21904-21951/com.akdndhrc.multipurposescope D/libGLESv1: STS_GLApi : DTS, ODTC are not allowed for Package : com.akdndhrc.multipurposescope
2021-02-16 18:19:31.700 21904-21951/com.akdndhrc.multipurposescope D/OpenGLRenderer: eglCreateWindowSurface = 0x70a51c3df0
2021-02-16 18:19:31.705 21904-21904/com.akdndhrc.multipurposescope D/SurfaceView: BG show() Surface(name=Background for - SurfaceView - com.akdndhrc.multipurposescope/com.akdndhrc.multipurposescope.MainActivity@5dcde6e@0) io.flutter.embedding.android.FlutterSurfaceView{5dcde6e V.E...... ......ID 0,0-1080,1920}
2021-02-16 18:19:31.719 21904-21904/com.akdndhrc.multipurposescope V/Surface: sf_framedrop debug : 0x4f4c, game : false, logging : 0
2021-02-16 18:19:31.719 21904-21904/com.akdndhrc.multipurposescope D/SurfaceView: surfaceCreated 1 io.flutter.embedding.android.FlutterSurfaceView{5dcde6e V.E...... ......ID 0,0-1080,1920}
2021-02-16 18:19:31.747 21904-21943/com.akdndhrc.multipurposescope I/FA: Tag Manager is not found and thus will not be used
2021-02-16 18:19:31.793 21904-21909/com.akdndhrc.multipurposescope I/zygote64: Do partial code cache collection, code=29KB, data=20KB
2021-02-16 18:19:31.794 21904-21909/com.akdndhrc.multipurposescope I/zygote64: After code cache collection, code=28KB, data=20KB
2021-02-16 18:19:31.794 21904-21909/com.akdndhrc.multipurposescope I/zygote64: Increasing code cache capacity to 128KB
2021-02-16 18:19:31.846 21904-21944/com.akdndhrc.multipurposescope I/flutter: Observatory listening on http://127.0.0.1:39889/K2QV5KtbiFM=/
2021-02-16 18:19:32.042 21904-21904/com.akdndhrc.multipurposescope D/SurfaceView: surfaceChanged (1080,1920) 1 io.flutter.embedding.android.FlutterSurfaceView{5dcde6e V.E...... ......ID 0,0-1080,1920}
2021-02-16 18:19:32.055 21904-21904/com.akdndhrc.multipurposescope D/ViewRootImpl@a1b73ed[MainActivity]: MSG_RESIZED_REPORT: frame=Rect(0, 0 - 1080, 1920) ci=Rect(0, 72 - 0, 0) vi=Rect(0, 72 - 0, 0) or=1
2021-02-16 18:19:32.055 21904-21904/com.akdndhrc.multipurposescope D/ViewRootImpl@a1b73ed[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1
2021-02-16 18:19:32.057 21904-21904/com.akdndhrc.multipurposescope V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@291f7d2 nm : com.akdndhrc.multipurposescope ic=null
2021-02-16 18:19:32.057 21904-21904/com.akdndhrc.multipurposescope I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
2021-02-16 18:19:32.079 21904-21904/com.akdndhrc.multipurposescope D/ViewRootImpl@a1b73ed[MainActivity]: Relayout returned: old=[0,0][1080,1920] new=[0,0][1080,1920] result=0x3 surface={valid=true 483817242624} changed=false
2021-02-16 18:19:32.095 21904-21951/com.akdndhrc.multipurposescope I/vndksupport: sphal namespace is not configured for this process. Loading /vendor/lib64/hw/gralloc.msm8996.so from the current namespace instead.
2021-02-16 18:19:32.105 21904-21904/com.akdndhrc.multipurposescope V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@14b0a3 nm : com.akdndhrc.multipurposescope ic=null
2021-02-16 18:19:34.854 21904-21935/com.akdndhrc.multipurposescope D/libGLESv2: STS_GLApi : DTS, ODTC are not allowed for Package : com.akdndhrc.multipurposescope
2021-02-16 18:20:02.894 21904-21904/com.akdndhrc.multipurposescope D/ViewRootImpl@a1b73ed[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0
2021-02-16 18:20:03.475 21904-21904/com.akdndhrc.multipurposescope D/ViewRootImpl@a1b73ed[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1
2021-02-16 18:20:03.820 21904-21904/com.akdndhrc.multipurposescope D/ViewRootImpl@a1b73ed[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0
2021-02-16 18:20:04.402 21904-21904/com.akdndhrc.multipurposescope D/ViewRootImpl@a1b73ed[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1
2021-02-16 18:21:10.112 21904-21904/com.akdndhrc.multipurposescope D/ViewRootImpl@a1b73ed[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0
2021-02-16 18:21:10.144 21904-21904/com.akdndhrc.multipurposescope D/SurfaceView: BG show() Surface(name=Background for - SurfaceView - com.akdndhrc.multipurposescope/com.akdndhrc.multipurposescope.MainActivity@5dcde6e@0) io.flutter.embedding.android.FlutterSurfaceView{5dcde6e V.E...... ........ 0,0-1080,1920}
2021-02-16 18:21:10.148 21904-21904/com.akdndhrc.multipurposescope D/SurfaceView: surfaceDestroyed 1 io.flutter.embedding.android.FlutterSurfaceView{5dcde6e V.E...... ........ 0,0-1080,1920}
2021-02-16 18:21:10.163 21904-21909/com.akdndhrc.multipurposescope I/zygote64: Do partial code cache collection, code=55KB, data=39KB
2021-02-16 18:21:10.172 21904-21909/com.akdndhrc.multipurposescope I/zygote64: After code cache collection, code=55KB, data=39KB
2021-02-16 18:21:10.172 21904-21909/com.akdndhrc.multipurposescope I/zygote64: Increasing code cache capacity to 256KB
2021-02-16 18:21:10.198 21904-21904/com.akdndhrc.multipurposescope D/SurfaceView: BG show() Surface(name=Background for - SurfaceView - com.akdndhrc.multipurposescope/com.akdndhrc.multipurposescope.MainActivity@5dcde6e@0) io.flutter.embedding.android.FlutterSurfaceView{5dcde6e V.E...... ........ 0,0-1080,1920}
2021-02-16 18:21:10.215 21904-21951/com.akdndhrc.multipurposescope D/OpenGLRenderer: eglDestroySurface = 0x70a51c3df0
2021-02-16 18:21:10.228 21904-21904/com.akdndhrc.multipurposescope D/ViewRootImpl@a1b73ed[MainActivity]: Relayout returned: old=[0,0][1080,1920] new=[0,0][1080,1920] result=0x5 surface={valid=false 0} changed=true
2021-02-16 18:21:10.278 21904-21904/com.akdndhrc.multipurposescope D/ViewRootImpl@a1b73ed[MainActivity]: Relayout returned: old=[0,0][1080,1920] new=[0,0][1080,1920] result=0x1 surface={valid=false 0} changed=false
2021-02-16 18:21:10.858 21904-21904/com.akdndhrc.multipurposescope V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@93de6a6 nm : com.akdndhrc.multipurposescope ic=null
2021-02-16 18:21:10.858 21904-21904/com.akdndhrc.multipurposescope I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
我搜索了很多我的问题,但似乎无法找到我的问题的解决方案。我猜这与导航小部件有关
答案 0 :(得分:3)
你错过了最重要的部分
<块引用>runApp()
这用于将您的小部件附加到屏幕上。
这会有所帮助:
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
答案 1 :(得分:2)
你必须在主函数中调用runApp();
main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp ()); // add this line
}