简体   繁体   中英

Flutter: Hot reload and hot restart not working after connecting to firebase background functionality

Flutter hot reload and hot restart stop working after doing the minimum to connect my app to a firebase project.

I have connected three different flutter projects to three different firebase projects and none of them have allowed me to hot reload or hot refresh. After following the instructions on firebase to connect my app the only thing I add is this.

main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(MyApp());
}

and I always get the same errors:

Unhandled exception:
Null check operator used on a null value
#0      IncrementalCompiler._initializeExperimentalInvalidation (package:front_end/src/fasta/incremental_compiler.dart:1226:53)
<asynchronous suspension>
#1      IncrementalCompiler.computeDelta.<anonymous closure> (package:front_end/src/fasta/incremental_compiler.dart:324:11)

<asynchronous suspension>
#2      IncrementalCompiler.compile (package:vm/incremental_compiler.dart:68:50)
<asynchronous suspension>
#3      FrontendCompiler.compile (package:frontend_server/frontend_server.dart:572:11)
<asynchronous suspension>
#4      listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1210:11)
<asynchronous suspension>

This is not Flutter's Hot reload and hot restart issue. This may occur due to the following:

  • Installed packages (pub).
  • Nullability

You should check the compatibility of some of your packages with the firebase package. Your log shows frontend_server.dart and incremental_compiler.dart contain null checks on null values.

If you are the creator of those files, you need to update the codebase by handling null this way:

if (value != null) {
    // do something
}

Else

flutter pub clean cache
flutter pub get
flutter build

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM