localizely / flutter-intl-vscode

This VS Code extension generates boilerplate code for localization of Flutter apps with official Dart Intl library
MIT License
87 stars 1 forks source link

Different code generated after running initialize #99

Open dgt-erik opened 1 year ago

dgt-erik commented 1 year ago

Describe the bug Me and a collegue have the same IDE, same extentions and versions installed. But Flutter intl generates different code in messages_all.dart

This is the code difference: Generated by my collegue:

 'de': () => new SynchronousFuture(null),
  'en': () => new SynchronousFuture(null),
  'nl': () => new SynchronousFuture(null),

Generated by me:

  'de': () => new Future.value(null),
  'en': () => new Future.value(null),
  'nl': () => new Future.value(null),

we both constantly push the changes to git when generating / adding keys. It is annoying because it generated more code changed then necessary.

This behavior changed and disappeared after i executed flutter Intl: Initialize. The difference, he added Intl, i did not. I cloned the repo and executed flutter pub get. and used "saving pubspec.yaml" to generate the files.

To Reproduce

Create a project etc, add intl according to install.
Run Flutter Intl: initialize as described.
commit and push to repository

Clone repository on different computer
Run "flutter pub get"
Add a key in arb file
add space to pubspec.yaml and save
messages_all.dart will be generated with new Future.value

Via this route, none of the files are generated when saving an arb file
lzoran commented 1 year ago

Hi @dgt-erik,

As of version 1.19.0, the logic for deciding which version of the code generator (the intl_utils package) to use has been changed.

The Flutter Intl >=1.19.0 extension checks:

Fix: Decide which version of the intl_utils package you want to use and specify it as a dev dependency or just globally activate that concrete version (e.g. flutter pub global activate intl_utils 2.8.1).
To check globally activated packages, run flutter pub global list.

Hope it helps!

pedrobrochero commented 1 year ago

A better approach for this is to set the intl_utils version in the pubspec.yml file (under dev dependencies), so everyone in the project will have the same version no matter which global version they have set.

Don't forget to run a flutter pub get after adding the dependency! After that, delete the intl generated folder an re-generate it.

Hope it works for you!