Try removing the declaration of '_locale'.dart(unused_element)
OverLoadedBurden opened this issue · 4 comments
while this is just a hint but i think it won't cost much time developing converting this:
/// `en`
String get _locale {
return Intl.message(
'en',
name: '_locale',
desc: '',
args: [],
);
}
to
/// `en`
/// ignore: unused_element
String get _locale {
return Intl.message(
'en',
name: '_locale',
desc: '',
args: [],
);
}
instead of manually modifying it every time we generate the files.
Hi @OverLoadedBurden
I am not sure get it, can you give more info?
This looks like your own string key getter, generated from ARB file, not some base l10n code.
Hi @OverLoadedBurden
I am not sure get it, can you give more info?
This looks like your own string key getter, generated from ARB file, not some base l10n code.
if i run flutter pub run intl_utils:generate
without "_locale":"my_locale_name"
i get this warning
INFO: No @@locale or _locale field found in intl_my_locale_name, assuming 'my_locale_name' based on the file name.
but because the required field name starting with _
the dart lang will consider it a private variable.
So we as the dev's can't use it and the flutter analyze
tool going to throw a warning because of it. So i suggest adding the
/// ignore: unused_element
hint before the _locale
field to prevent this warning from showing up.
If you name your ARB files as intl_en.arb
(recommended) it will automatically conclude the locale from the file name and you can ignore the warning in such a case.
If you don't follow that naming convention, you should add the following key-value pair into ARB files:
"@@locale": "en"
However, if you use Flutter Intl plugin for Android Studio or VS Code and create ARB files through its commands, it will create file names as expected.
didn't know that @@locale
is the same as _locale
thanks.