0

After installing flame and when i run my app in flutter (flutter run). I got a long error regarding null safety:

Running Gradle task 'assembleDebug'...
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:

 - package:flame
 - package:ordered_set
 - package:box2d_flame
 - package:audioplayers
 - package:path_provider
 - package:flutter_svg
 - package:path_provider_linux
 - package:path_provider_windows
 - package:path_provider_platform_interface
 - package:uuid
 - package:xdg_directories
 - package:plugin_platform_interface
 - package:crypto
 - package:convert
 - package:path_drawing
 - package:xml
 - package:path_parsing
 - package:petitparser
...
spydon
  • 9,372
  • 6
  • 33
  • 63

1 Answers1

1

You are using the old version (0.29.3) which doesn't support null-safety, you have to use one of the newer release candidates of 1.0.0.

dependencies:
  flame: ^1.0.0-releasecandidate.11

https://pub.dev/packages/flame/versions/1.0.0-releasecandidate.11/install

spydon
  • 9,372
  • 6
  • 33
  • 63
  • Thank you for your response but now it says – Gaurav Srivastava May 26 '21 at 16:25
  • lib/main.dart:7:3: Error: 'Util' isn't a type. Util flameUtil = Util(); ^^^^ lib/main.dart:7:20: Error: Method not found: 'Util'. Util flameUtil = Util(); ^^^^ FAILURE: Build failed with an exception. – Gaurav Srivastava May 26 '21 at 16:29
  • That is not a valid class in v1 (you probably got it from a very old flame version), we have moved out all of the Util methods to other classes, for example Device, you can see the docs for them here: https://flame-engine.org/docs/#/util – spydon May 26 '21 at 20:56
  • Thank you so much. Helped me a lot – Gaurav Srivastava May 26 '21 at 23:28
  • @GauravSrivastava please accept the answer so that more can get help from it :) It's the checkmark underneath the up and down arrows. – spydon May 27 '21 at 08:23