我制作了一个新应用程序,并在Decs中执行了这些步骤,但当我运行该应用程序时,它运行正常,但在控制台上仍然有错误。
此错误
6.26.0 - [Firebase/Core][I-COR000005] No app has been configured yet.
当我第一次在模拟器上运行应用程序时,它就会在控制台上显示,然后当我再次运行它时,它就不会显示在控制台上。
我的控制台错误:
Launching lib/main.dart on iPhone 11 Pro in debug mode...
Running Xcode build...
Xcode build done. 21.1s
6.26.0 - [Firebase/Core][I-COR000005] No app has been configured yet.
Waiting for iPhone 11 Pro to report its views...
Debug service listening on ws://127.0.0.1:57659/LoVj1aW15Pg=/ws
Syncing files to device iPhone 11 Pro...
我把
FirebaseSDKVersion
在我的
podfile
这样地
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
# Override Firebase SDK Version
FirebaseSDKVersion = '21.1.0'
我的
pub file
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
firebase_core: ^0.5.0
firebase_auth: "^0.18.0+1"
我用了同样的
StatefulWidget
我的测试代码中的文档示例。。。
import 'package:flutter/material.dart';
// Import the firebase_core plugin
import 'package:firebase_core/firebase_core.dart';
void main() {
runApp(App());
}
class App extends StatefulWidget {
_AppState createState() => _AppState();
}
class _AppState extends State<App> {
// Set default `_initialized` and `_error` state to false
bool _initialized = false;
bool _error = false;
// Define an async function to initialize FlutterFire
void initializeFlutterFire() async {
try {
// Wait for Firebase to initialize and set `_initialized` state to true
await Firebase.initializeApp();
setState(() {
_initialized = true;
});
} catch (e) {
// Set `_error` state to true if Firebase initialization fails
setState(() {
_error = true;
});
}
}
@override
void initState() {
initializeFlutterFire();
super.initState();
}
@override
Widget build(BuildContext context) {
// Show error message if initialization failed
if (_error) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Text('Error 1'),
),
),
);
}
// Show a loader until FlutterFire is initialized
if (!_initialized) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Text('loading'),
),
),
);
}
return MaterialApp(
home: Scaffold(
body: Center(
child: Text(' my awesome app'),
),
),
);
}
}