【发布时间】:2022-12-30 02:21:26
【问题描述】:
我正在尝试运行我的应用程序,但出现以下错误
[core/no-app] 没有创建 Firebase 应用“[DEFAULT]” - 调用 Firebase.initializeApp()
我已经打电话给firebase.initializeApp(),但错误仍然是一样的。
这是我的主文件代码
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider(
create: (_) => AppointmentsProvider(),
child: MaterialApp(
title: 'Car Wash App',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: FutureBuilder(
future: Firebase.initializeApp(),
builder: (ctx, snap) =>
snap.connectionState == ConnectionState.waiting
? Center(
child: Text('Loading...'),
)
: StreamBuilder(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (ctx, snapShot) =>
snapShot.hasData ? HomePage() : UserAuth(),
),
),
routes: {
HomePage.routeName: (_) => HomePage(),
HistoryPage.routeName: (_) => HistoryPage(),
MyAppointments.routeName: (_) => MyAppointments(),
PackagesPage.routeName: (_) => PackagesPage(),
VehicleType.routeName: (_) => VehicleType(),
SlotPage.routeName: (_) => SlotPage(),
ExtraServicesPage.routeName: (_) => ExtraServicesPage(),
SummaryPage.routeName: (_) => SummaryPage(),
DetailedScreen.routeName: (_) => DetailedScreen(),
PaymentMethodScreen.routeName: (_) => PaymentMethodScreen(),
},
),
);
}
}
非常感谢任何形式的帮助。谢谢
【问题讨论】:
-
Baimam Boukar 的回答对您有帮助吗?
-
它给出了这个错误“[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: [core/not-initialized] Firebase has not been correctly initialized.”