6

The problem:

some of pub packages doesn't support null safety yet.

For example intl_translation cannot parse a file with null safety operators and throw Errors as below if any of symbols (as ?, ! etc) found.

Invalid argument(s): Parsing errors in lib/localizations/MainLocalizations.dart
#0      MessageExtraction._parseCompilationUnit (package:intl_translation/extract_messages.dart:117:7)
#1      MessageExtraction.parseContent (package:intl_translation/extract_messages.dart:102:14)
#2      MessageExtraction.parseFile (package:intl_translation/extract_messages.dart:87:12)
#3      main (file:///.../flutter/.pub-cache/hosted/pub.dartlang.org/intl_translation-0.17.10+1/bin/extract_to_arb.dart:98:31)
#4      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:281:32)
#5      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

Then it generates dart files which are not using null safety too and it causes numerous errors during $ flutter run.

So is there a way to disable warnings or null safety for at least success compilation? because $ flutter run --no-sound-null-safety doesn't helps :(

Thank you for any help!

Arenukvern
  • 438
  • 6
  • 11

1 Answers1

11

You can disable it per library. This requires to add special comment at the beginning of file.
Example.

// @dart=2.10
import 'foo.dart';
mezoni
  • 10,684
  • 4
  • 32
  • 54
  • Tested, exactly what is needed, thank you very much! It switched whole file to specified language version, not just library:) – Arenukvern Feb 07 '21 at 21:40
  • Is there a way to just get the library in that version but have the rest of the file remain the current version? – Machisuji Feb 27 '21 at 14:11
  • This worked perfectly for Android. Thank you. But still, I'm not able to run in iOS. Facing errors. – MubarakZade Jun 30 '21 at 14:24