localizely / intl_utils

Dart package that creates a binding between your translations from .arb files and your Flutter app
BSD 3-Clause "New" or "Revised" License
134 stars 81 forks source link

Allow customized line length for generated code file #128

Closed ludy-auror closed 1 month ago

ludy-auror commented 3 months ago

Hi guys, I am using latest Flutter Intl plugin 1.18.5 for Android Sutdio.

I am wondering if a new configuration option can be added to set the line length (number of characters before line break) for the generated code file like messages_xx.dart and l10n.dart.

The reason is that dart format allows setting custom line length, and our project is using a more generous 120 characters per line than the default 80. In this case, each time Flutter Intl plugin is invoked, the messages_xx.dart and l10n.dart files change unnecessarily from 120 per line back to 80 per line.

It would be nice to have a new configuration option can be added to pubspec.yaml, so that the generated files have the correct line length, for example:

flutter_intl:
  enabled: true
  class_name: S
  line_length: 120 # <-- Propose to add this new config 

Hope I am posting to the right repo, as far as I understand, the Flutter Intl plugin invokes intl_utils behind the scene.

Thanks in advance

lzoran commented 1 month ago

Thank you for the feedback and proposal!

Regarding the addition of a special configuration option for line length and code formatting, I believe that could increase the complexity of using the package. Limiting to only essential configuration options makes the package easier to understand and use. Furthermore, I'm unsure about the practice of mixing code formatting configurations with regular package configurations. I view code formatting as a stylistic step that can improve consistency, readability, reduce errors, and generally enhance code quality. However, the generated code is just boilerplate, required for Flutter localization, and should not be manually modified. It is generated to save us the effort of writing it manually each time we add or change localization messages. Instead of modifying generated files, I would prefer to exclude them from formatting, similar to how they can be excluded from code analysis.