Firebase身份验证在部署后不工作.扑动Web应用程序显示空白的白色屏幕



我部署了我的Flutter Web应用程序与Firebase Auth和Firebase Firestore与flutter build webfirebase deploy

问题是在我部署web应用程序后,我只看到一个空白的白色屏幕。

Web应用程序由Firebase托管。

有人遇到过这个问题吗?

我的pubspec.yaml:

dependencies:
blur: ^3.1.0
cloud_firestore: ^4.4.5
cupertino_icons: ^1.0.2
email_validator: ^2.1.17
firebase_auth: ^4.4.0
firebase_auth_web: ^5.3.0
firebase_core: ^2.9.0
fl_chart: ^0.61.0
fl_heatmap: ^0.2.0
flutter:
sdk: flutter
flutter_heatmap_calendar: ^1.0.5
flutter_styled_toast: ^2.1.3
fluttertoast: ^8.2.1
google_fonts: ^4.0.3
google_maps_flutter: ^2.2.5
google_maps_flutter_web: ^0.4.0+7
intl: 0.17.0
pie_chart: ^5.3.2
pointer_interceptor: ^0.9.3+4
provider: ^6.0.5
url_launcher: ^6.1.10
dev_dependencies:
flutter_lints: ^2.0.0
flutter_test:
sdk: flutter

My void main():

void main() async {
WidgetsFlutterBinding.ensureInitialized();
const FirebaseOptions firebaseOptions = FirebaseOptions(
apiKey: "apiKey",
projectId: "projectId",
messagingSenderId: "messagingSenderId",
appId: "appId",
);
await Firebase.initializeApp(name: "name", options: firebaseOptions);
runApp(const MyApp());
}

MyApp部件:

class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider(
create: (context) => TimeProvider(),
),
],
child: MaterialApp(
debugShowCheckedModeBanner: true,
key: _key,
scaffoldMessengerKey: Utils.messengerKey,
home: StreamBuilder<User?>(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return const LoadingAuthScreen();
} else {
return const AuthPage();
}
},
), //const DrawerHome(),
),
);
}
}

脚本标记:

<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.18.0/firebase-app.js";
import { getAuth } from "https://www.gstatic.com/firebasejs/9.18.0/firebase-auth.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.18.0/firebase-analytics.js";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "apiKey",
authDomain: "authDomain",
databaseURL: "databaseURL",
projectId: "projectId",
storageBucket: "storageBucket",
messagingSenderId: "messagingSenderId",
appId: "appId",
measurementId: "measurementId"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
</script>

我过去遇到过类似的问题,我必须做些什么来解决它:

  • runflutter clean
  • 删除web中的旧配置
  • 尝试使用flutterfire_cli在Flutter中集成Firebase的新方法

看一遍下面的文档

https://firebase.google.com/docs/flutter/setup?platform=web

最新更新