Closed talamaska closed 6 months ago
Hey @talamaska
I'm not certain what the issue being referred to is. Please attach a minimal project to reproduce this and I'll find some time to take a look.
ok, let's start from here
running dart run l10n_mapper_generator --gen-mapper
produces
import 'package:l10n_mapper_annotation/l10n_mapper_annotation.dart';
part 'app_localizations.g.dart';
@L10nMapperAnnotation(mapperExtension: L10nMapperExtension(l10n: true, locale: true, l10nParser: true), translationConfig: TranslationConfig(nullable: false, message: 'Cannot find translation-key!'),)
In the app_localization.dart
Every time, flutter pub get
or flutter run
are called,
the above snippet disapears. So right before compiling it, this is gone.
As a result import 'package:myapp/l10n/app_localization.dart';
cannot find the data from the app_localization.g.dart - no extension methods, no map. Because
app_localization.g.dart has part of 'app_localizations.dart';
but
app_localizations.dart doesn't have part 'app_localizations.g.dart';
So dart errors everywhere where i have imported the localization file.
Hey @talamaska, I see your issues and this is a good proposition.
This is resulted from flutter regenerating generated files on pub run commands and even flutter run. I'll find some time to look into this and weigh feasibility given my tight schedules.
Will indicate here when this has been resolved
If there was a way to disable the flutter_localization auto-generation, this wouldn't be a problem.
Hey @talamaska this issues has been fixed in l10n_mapper_generator: ^2.0.0
. You can confirm this. Please indicate here if this is still persisting.
I'm encountering an error when running build_runner
[SEVERE] Conflicting outputs
Both source_gen:combining_builder and l10n_mapper_generator:l10n_mapper_builder may output lib/app/app.g.dart. Potential outputs must be unique across all builders. See https://github.com/dart-lang/build/blob/master/docs/faq.md#why-do-builders-need-unique-outputs
I have 2 more build_runner stuff that are running - json_serializer and flutter_gen for assets. Nt sure but maybe, you can change the suffix from g to something else like moor/drift did it. Or should configure the build.yaml to run first one builder than the second one in, series not parallel.
This is not an issue but might result to clashing as in your case. Please open a new ticket specific for this feature request @talamaska
Basically after every flutter pub get and flutter run the modifications on the app_localizations are gone. Having the context extensions imported in a lot of files pointing to app_localizations.dart files is breaking, because of the lack of the "part' file I'm wondering, is it possible to make the generated file independent? Like not being a part file? And with a different name? for example the gen_l10n tools doesn't add the g suffix and is generating a file called l10n.dart with a single extension in it. Also why do I need the annotation since I have declared the json file? is it possible to make the generation work without that annotation and the part file import?