Closed berdroid closed 2 years ago
@berdroid Is it maybe related to this https://github.com/localizely/flutter-intl-intellij/issues/64#issuecomment-810458794 ?
If it finds
environment:
sdk: ">=2.12.0-0 <3.0.0"
then it will generate null safe code
@aleksakrstic That would be fine, as Dart would expect null-safe code.
However, I have
environment:
sdk: ">=2.10.0 <3.0.0"
So any generated code using null-safety syntax like
static S? _current;
static S get current {
assert(_current != null,
'No instance of S was loaded. Try to initialize the S delegate before accessing S.current.');
return _current!;
}
will cause error message from the analyzer like error: This requires the 'non-nullable' language feature to be enabled. (experiment_not_enabled at [xxx] lib\generated\l10n.dart:18)
I have Dart SDK 2.15 installed along with Flutter 2.8.0
Hi @berdroid,
Maybe IDE triggered the generation of localization code a little earlier than it should (e.g. not finished editing of the pubspec.yaml
file) 😕
To fix that, maybe updating the pubspec.yaml
file could help:
pubspec.yaml
file.Ctrl + S
to trigger generation.Alternatively, you can manually run the generation of the not-null safe code from the root of the project:
flutter pub global activate intl_utils 1.9.0
flutter pub global run intl_utils:generate
Hi @lzoran Thanks you for your suggestions.
As is turns out,intl_tools 1.9.0
was already activated, so running generate
produces the same null-safe code again.
Running flutter clean
did not change that either.
Could this possible be a bug in either intl_tools
or the plugin that causes the generation of null-safe code even if the Dart SDK
version is set to 2.10
in pubspec.yaml
, while SDK version 2.15
is actually installed?
That's really weird. 😕
The null-safe code can be generated only with the intl_utils ^2.0.0
.
To be sure that this is not some issue with cache, could you try to re-activate the intl_utils
package.
flutter pub global deactivate intl_utils
flutter pub global activate intl_utils 1.9.0
flutter pub global list
(should show intl_utils 1.9.0
)
flutter pub global run intl_utils:generate
(or alternatively trigger generation by updating one ARB file and save)
Thanks for the suggestions. I'll try that when I'll be back at work. For now I did a fresh check-out the project on my MacBook and the problem did not show any longer.
@lzoran I followed the steps outlined above and this did resolve the issue with the working copy on my Windows machine. A assume that temporarily enabling null-safety changed some internal settings that did not reset properly when I change the Dart SDK version back to 2.10.0.
Thanks a lot for your support.
After upgrading the plugin to version 1.16.0-2020.3 and experimenting with migration to null-safety the plugin started to generate null-safe code, even though I reset to SDK version to 2.10
How can I revert the code generation behavior to generate code for Dart 2.10?