Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
94da7248
Unverified
Commit
94da7248
authored
Jul 15, 2022
by
Christopher Fujino
Committed by
GitHub
Jul 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] fix RangeError in gen-l10n by checking for empty string (#107604)
parent
d7285394
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
3 deletions
+39
-3
gen_l10n.dart
packages/flutter_tools/lib/src/localizations/gen_l10n.dart
+3
-0
gen_l10n_types.dart
...s/flutter_tools/lib/src/localizations/gen_l10n_types.dart
+3
-0
generate_localizations_test.dart
...tools/test/general.shard/generate_localizations_test.dart
+33
-3
No files found.
packages/flutter_tools/lib/src/localizations/gen_l10n.dart
View file @
94da7248
...
...
@@ -1050,6 +1050,9 @@ class LocalizationsGenerator {
}
static
bool
_isValidGetterAndMethodName
(
String
name
)
{
if
(
name
.
isEmpty
)
{
return
false
;
}
// Public Dart method name must not start with an underscore
if
(
name
[
0
]
==
'_'
)
{
return
false
;
...
...
packages/flutter_tools/lib/src/localizations/gen_l10n_types.dart
View file @
94da7248
...
...
@@ -124,6 +124,9 @@ class L10nException implements Exception {
L10nException
(
this
.
message
);
final
String
message
;
@override
String
toString
()
=>
message
;
}
// One optional named parameter to be used by a NumberFormat.
...
...
packages/flutter_tools/test/general.shard/generate_localizations_test.dart
View file @
94da7248
...
...
@@ -992,9 +992,7 @@ class AppLocalizationsEn extends AppLocalizations {
});
testWithoutContext
(
'throws an error attempting to add preferred locales '
'when there is no corresponding arb file for that '
'locale'
,
'throws an error attempting to add preferred locales when there is no corresponding arb file for that locale'
,
()
{
final
Directory
l10nDirectory
=
fs
.
currentDirectory
.
childDirectory
(
'lib'
).
childDirectory
(
'l10n'
)
..
createSync
(
recursive:
true
);
...
...
@@ -1161,6 +1159,38 @@ class AppLocalizationsEn extends AppLocalizations {
)),
);
});
testWithoutContext
(
'throws when an empty string is used as a key'
,
()
{
const
String
arbFileStringWithEmptyResourceId
=
'''
{
"market": "MARKET",
"": {
"description": "This key is invalid"
}
}'''
;
final
Directory
l10nDirectory
=
fs
.
currentDirectory
.
childDirectory
(
'lib'
).
childDirectory
(
'l10n'
)
..
createSync
(
recursive:
true
);
l10nDirectory
.
childFile
(
'app_en.arb'
)
.
writeAsStringSync
(
arbFileStringWithEmptyResourceId
);
expect
(
()
=>
LocalizationsGenerator
(
fileSystem:
fs
,
inputPathString:
defaultL10nPathString
,
outputPathString:
defaultL10nPathString
,
templateArbFileName:
'app_en.arb'
,
outputFileString:
defaultOutputFileString
,
classNameString:
defaultClassNameString
,
).
loadResources
(),
throwsA
(
isA
<
L10nException
>().
having
(
(
L10nException
e
)
=>
e
.
message
,
'message'
,
contains
(
'Invalid ARB resource name ""'
),
)),
);
});
testWithoutContext
(
'throws when the same locale is detected more than once'
,
()
{
const
String
secondMessageArbFileString
=
'''
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment