import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:todo_firebase/auth/authscreen.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:todo_firebase/screens/home.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
//initilization of Firebase app
// other Firebase service initialization
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: StreamBuilder(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, usersnapshot) {
if (usersnapshot.hasData) {
return Home();
} else {
return AuthScreen();
}
},
),
debugShowCheckedModeBanner: false,
theme: ThemeData(brightness: Brightness.light, primaryColor: Colors.blue),
// ignore: dead_code
);
}
}
這是我的 main.dart 代碼。我在'await Firebase.initializeApp()'得到以下輸出: MissingPluginException (MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core))
我正在嘗試制作一個日常任務應用程式,但每當我使用 VSCode 執行它時,它都會構建一個顯示為空白的 Windows 應用程式。我已經在 lib(身份驗證和主頁)??、main.dart 和 pubspec.yaml 的不同部分撰寫了整個代碼,但它沒有執行。請提供修復錯誤的方法,并使我的應用程式正常作業。
uj5u.com熱心網友回復:
今天早上有這個問題..這是一個多么大的問題!我花了幾個小時才弄清楚。不過現在一切正常!
我做了什么?我嘗試清理我的專案,洗掉了 ios 檔案并運行flutter create .了幾次但沒有運氣......把我的頭發拉出來了!
什么修好了?
- 更新你的寶石
- 第 5 次洗掉 ios 檔案 (LOL)
- 洗掉 xcode 中的“派生資料”并清理 xcode 中的構建檔案夾
在您的專案中運行flutter clean,然后運行flutter pub cache repair
然后您需要使用最新版本的 firebase 核心等手動更新您的 pubspec.yaml。是的,請確保先洗掉鎖定檔案,然后手動更新依賴項。 不要運行 flutter pub upgrade。行不通..只需手動添加它們:(
這是我手動添加到我的 pubspec.yaml 中的:
cloud_firestore: ^3.2.1
firebase_core: ^1.19.1
firebase_storage: ^10.3.1
firebase_auth: ^3.4.1
firebase_messaging: ^11.4.4
uj5u.com熱心網友回復:
首先你的應用程式沒有在設備上運行如果運行然后停止它然后觸發這些命令
Flutter clean
然后
Flutter pub get
然后運行你的專案
uj5u.com熱心網友回復:
最新的firebase_core 1.19.0版本好像有問題嘗試使用之前的版本:
firebase_core: ^1.18.0
至少這為我解決了問題。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/498281.html
上一篇:Devcontainer:打開容器時如何使用自定義命令打開終端?
下一篇:node.js上的詢問者
