颤振网出现白屏

  • 本文关键字:白屏 flutter dart
  • 更新时间 :
  • 英文 :


web应用程序工作正常,但当我添加firebase时,它开始给出一个空白屏幕并出现错误:

错误:断言失败:文件:///D:/颤振颤振/.pub-cache/托管/pub.dartlang.org/firebase_core_web-1.6.6/lib/src/firebase_core_web.dart: 273:11

我正在使用主分支

Pubspec.yaml:

version: 1.0.0+1
environment:
sdk: '>=2.18.0-228.0.dev <3.0.0'
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
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: ^1.0.2
flutter_svg:  # help us to use SVG in our app
provider: # for State management
firebase_auth:
shared_preferences: ^2.0.15
firebase_core: ^1.18.0
firebase_core_web: ^1.6.5
cloud_firestore: ^3.2.1
image_picker: ^0.8.5+3
firebase_storage: ^10.3.1
dev_dependencies:
flutter_test:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^2.0.0

index . html:

<!DOCTYPE html>
<html>
<head>
<!--
If you are serving your web app in a path other than the root, change the
href value below to reflect the base path you are serving from.
The path provided below has to start and end with a slash "/" in order for
it to work correctly.
For more details:
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
This is a placeholder for base href that will be replaced by the value of
the `--base-href` argument provided to `flutter build`.
-->
<base href="$FLUTTER_BASE_HREF">
<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="A new Flutter project.">
<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="ecomm">
<link rel="apple-touch-icon" href="icons/Icon-192.png">
<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png"/>
<title>ecomm</title>
<link rel="manifest" href="manifest.json">
<script>
// The value below is injected by flutter build, do not touch.
var serviceWorkerVersion = null;
</script>
<!-- This script adds the flutter initialization JS code -->
<script src="flutter.js" defer></script>
</head>
<body>
<script>
window.addEventListener('load', function(ev) {
// Download main.dart.js
_flutter.loader.loadEntrypoint({
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
}
}).then(function(engineInitializer) {
return engineInitializer.initializeEngine();
}).then(function(appRunner) {
return appRunner.runApp();
});
});
</script>
</body>
</html>

你需要在主文件中正确初始化你的firebase应用。

main() async{
WidgetsFlutterBinding.ensureInitialized();

await Firebase.initializeApp(
options: FirebaseOptions(
apiKey: ********, 
appId: ******, 
messagingSenderId: **, projectId: *****);
}

最新更新