enable lint prefer_interpolation_to_compose_strings (#83407)

This commit is contained in:
Alexandre Ardhuin
2021-06-01 20:14:06 +02:00
committed by GitHub
parent 71e711547f
commit 34059eec2c
96 changed files with 367 additions and 345 deletions

View File

@@ -213,9 +213,9 @@ class ListItem extends StatelessWidget {
if (count < 10000) {
return count.toString();
} else if (count < 100000) {
return (count / 10000).toStringAsPrecision(2) + 'w';
return '${(count / 10000).toStringAsPrecision(2)}w';
} else {
return (count / 10000).floor().toString() + 'w';
return '${(count / 10000).floor()}w';
}
}

View File

@@ -33,7 +33,7 @@ class StockRow extends StatelessWidget {
final String lastSale = '\$${stock.lastSale.toStringAsFixed(2)}';
String changeInPrice = '${stock.percentChange.toStringAsFixed(2)}%';
if (stock.percentChange > 0)
changeInPrice = '+' + changeInPrice;
changeInPrice = '+$changeInPrice';
return InkWell(
key: ValueKey<String>(stock.symbol),
onTap: _getHandler(onPressed),

View File

@@ -22,7 +22,7 @@ class _StockSymbolView extends StatelessWidget {
final String lastSale = '\$${stock.lastSale.toStringAsFixed(2)}';
String changeInPrice = '${stock.percentChange.toStringAsFixed(2)}%';
if (stock.percentChange > 0)
changeInPrice = '+' + changeInPrice;
changeInPrice = '+$changeInPrice';
final TextStyle headings = Theme.of(context).textTheme.bodyText1!;
return Container(

View File

@@ -243,8 +243,8 @@ Future<void> verifyNoMissingLicense(String workingDirectory, { bool checkMinimum
await _verifyNoMissingLicenseForExtension(workingDirectory, 'swift', overrideMinimumMatches ?? 10, _generateLicense('// '));
await _verifyNoMissingLicenseForExtension(workingDirectory, 'gradle', overrideMinimumMatches ?? 80, _generateLicense('// '));
await _verifyNoMissingLicenseForExtension(workingDirectory, 'gn', overrideMinimumMatches ?? 0, _generateLicense('# '));
await _verifyNoMissingLicenseForExtension(workingDirectory, 'sh', overrideMinimumMatches ?? 1, '#!/usr/bin/env bash\n' + _generateLicense('# '));
await _verifyNoMissingLicenseForExtension(workingDirectory, 'bat', overrideMinimumMatches ?? 1, '@ECHO off\n' + _generateLicense('REM '));
await _verifyNoMissingLicenseForExtension(workingDirectory, 'sh', overrideMinimumMatches ?? 1, '#!/usr/bin/env bash\n${_generateLicense('# ')}');
await _verifyNoMissingLicenseForExtension(workingDirectory, 'bat', overrideMinimumMatches ?? 1, '@ECHO off\n${_generateLicense('REM ')}');
await _verifyNoMissingLicenseForExtension(workingDirectory, 'ps1', overrideMinimumMatches ?? 1, _generateLicense('# '));
await _verifyNoMissingLicenseForExtension(workingDirectory, 'html', overrideMinimumMatches ?? 1, '<!DOCTYPE HTML>\n<!-- ${_generateLicense('')} -->', trailingBlank: false);
await _verifyNoMissingLicenseForExtension(workingDirectory, 'xml', overrideMinimumMatches ?? 1, '<!-- ${_generateLicense('')} -->');
@@ -252,7 +252,7 @@ Future<void> verifyNoMissingLicense(String workingDirectory, { bool checkMinimum
Future<void> _verifyNoMissingLicenseForExtension(String workingDirectory, String extension, int minimumMatches, String license, { bool trailingBlank = true }) async {
assert(!license.endsWith('\n'));
final String licensePattern = license + '\n' + (trailingBlank ? '\n' : '');
final String licensePattern = '$license\n${trailingBlank ? '\n' : ''}';
final List<String> errors = <String>[];
await for (final File file in _allFiles(workingDirectory, extension, minimumMatches: minimumMatches)) {
final String contents = file.readAsStringSync().replaceAll('\r\n', '\n');
@@ -317,13 +317,13 @@ Future<void> verifyNoBadImportsInFlutter(String workingDirectory) async {
.map<String>((Directory entity) => path.basename(entity.path))
.toList()..sort();
if (!_listEquals<String>(packages, directories)) {
errors.add(
'flutter/lib/*.dart does not match flutter/lib/src/*/:\n'
'These are the exported packages:\n' +
packages.map<String>((String path) => ' lib/$path.dart').join('\n') +
'These are the directories:\n' +
directories.map<String>((String path) => ' lib/src/$path/').join('\n')
);
errors.add(<String>[
'flutter/lib/*.dart does not match flutter/lib/src/*/:',
'These are the exported packages:',
...packages.map<String>((String path) => ' lib/$path.dart'),
'These are the directories:',
...directories.map<String>((String path) => ' lib/src/$path/')
].join('\n'));
}
// Verify that the imports are well-ordered.
final Map<String, Set<String>> dependencyMap = <String, Set<String>>{};
@@ -347,7 +347,7 @@ Future<void> verifyNoBadImportsInFlutter(String workingDirectory) async {
continue;
// Sanity check before performing _deepSearch, to ensure there's no rogue
// dependencies.
final String validFilenames = dependencyMap.keys.map((String name) => name + '.dart').join(', ');
final String validFilenames = dependencyMap.keys.map((String name) => '$name.dart').join(', ');
errors.add(
'$key imported package:flutter/$dependency.dart '
'which is not one of the valid exports { $validFilenames }.\n'
@@ -359,10 +359,7 @@ Future<void> verifyNoBadImportsInFlutter(String workingDirectory) async {
for (final String package in dependencyMap.keys) {
final List<String> loop = _deepSearch<String>(dependencyMap, package);
if (loop != null) {
errors.add(
'${yellow}Dependency loop:$reset ' +
loop.join(' depends on ')
);
errors.add('${yellow}Dependency loop:$reset ${loop.join(' depends on ')}');
}
}
// Fail if any errors

View File

@@ -636,7 +636,7 @@ Future<void> _runFrameworkTests() async {
await _runFlutterTest(
path.join(flutterRoot, 'packages', 'flutter'),
options: <String>['--dart-define=dart.vm.product=true', ...soundNullSafetyOptions],
tests: <String>[ 'test_release' + path.separator ],
tests: <String>['test_release${path.separator}'],
);
}

View File

@@ -41,28 +41,31 @@ void main() {
test('analyze.dart - verifyDeprecations', () async {
final String result = await capture(() => verifyDeprecations(testRootPath, minimumMatches: 2), exitCode: 1);
final String lines = <String>[
'test/analyze-test-input/root/packages/foo/deprecation.dart:12: Deprecation notice does not match required pattern.',
'test/analyze-test-input/root/packages/foo/deprecation.dart:18: Deprecation notice should be a grammatically correct sentence and start with a capital letter; see style guide: STYLE_GUIDE_URL',
'test/analyze-test-input/root/packages/foo/deprecation.dart:25: Deprecation notice should be a grammatically correct sentence and end with a period.',
'test/analyze-test-input/root/packages/foo/deprecation.dart:29: Deprecation notice does not match required pattern.',
'test/analyze-test-input/root/packages/foo/deprecation.dart:32: Deprecation notice does not match required pattern.',
'test/analyze-test-input/root/packages/foo/deprecation.dart:37: Deprecation notice does not match required pattern.',
'test/analyze-test-input/root/packages/foo/deprecation.dart:41: Deprecation notice does not match required pattern.',
'test/analyze-test-input/root/packages/foo/deprecation.dart:48: End of deprecation notice does not match required pattern.',
'test/analyze-test-input/root/packages/foo/deprecation.dart:51: Unexpected deprecation notice indent.',
'test/analyze-test-input/root/packages/foo/deprecation.dart:70: Deprecation notice does not accurately indicate a dev branch version number; please see RELEASES_URL to find the latest dev build version number.',
'test/analyze-test-input/root/packages/foo/deprecation.dart:76: Deprecation notice does not accurately indicate a dev branch version number; please see RELEASES_URL to find the latest dev build version number.',
'test/analyze-test-input/root/packages/foo/deprecation.dart:82: Deprecation notice does not accurately indicate a dev branch version number; please see RELEASES_URL to find the latest dev build version number.',
'test/analyze-test-input/root/packages/foo/deprecation.dart:99: Deprecation notice does not match required pattern. You might have used double quotes (") for the string instead of single quotes (\').',
]
.map((String line) {
return line
.replaceAll('/', Platform.isWindows ? r'\' : '/')
.replaceAll('STYLE_GUIDE_URL', 'https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo')
.replaceAll('RELEASES_URL', 'https://flutter.dev/docs/development/tools/sdk/releases');
})
.join('\n');
expect(result,
'━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'
+
(
'test/analyze-test-input/root/packages/foo/deprecation.dart:12: Deprecation notice does not match required pattern.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:18: Deprecation notice should be a grammatically correct sentence and start with a capital letter; see style guide: STYLE_GUIDE_URL\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:25: Deprecation notice should be a grammatically correct sentence and end with a period.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:29: Deprecation notice does not match required pattern.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:32: Deprecation notice does not match required pattern.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:37: Deprecation notice does not match required pattern.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:41: Deprecation notice does not match required pattern.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:48: End of deprecation notice does not match required pattern.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:51: Unexpected deprecation notice indent.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:70: Deprecation notice does not accurately indicate a dev branch version number; please see RELEASES_URL to find the latest dev build version number.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:76: Deprecation notice does not accurately indicate a dev branch version number; please see RELEASES_URL to find the latest dev build version number.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:82: Deprecation notice does not accurately indicate a dev branch version number; please see RELEASES_URL to find the latest dev build version number.\n'
'test/analyze-test-input/root/packages/foo/deprecation.dart:99: Deprecation notice does not match required pattern. You might have used double quotes (") for the string instead of single quotes (\').\n'
.replaceAll('/', Platform.isWindows ? r'\' : '/')
.replaceAll('STYLE_GUIDE_URL', 'https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo')
.replaceAll('RELEASES_URL', 'https://flutter.dev/docs/development/tools/sdk/releases')
)
+
'$lines\n'
'See: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes\n'
'━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'
);
@@ -70,15 +73,12 @@ void main() {
test('analyze.dart - verifyNoMissingLicense', () async {
final String result = await capture(() => verifyNoMissingLicense(testRootPath, checkMinimums: false), exitCode: 1);
final String lines = 'test/analyze-test-input/root/packages/foo/foo.dart'
.replaceAll('/', Platform.isWindows ? r'\' : '/');
expect(result,
'━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'
+
(
'The following 1 file does not have the right license header:\n'
'test/analyze-test-input/root/packages/foo/foo.dart\n'
.replaceAll('/', Platform.isWindows ? r'\' : '/')
)
+
'The following 1 file does not have the right license header:\n'
'$lines\n'
'The expected license header is:\n'
'// Copyright 2014 The Flutter Authors. All rights reserved.\n'
'// Use of this source code is governed by a BSD-style license that can be\n'
@@ -90,15 +90,15 @@ void main() {
test('analyze.dart - verifyNoTrailingSpaces', () async {
final String result = await capture(() => verifyNoTrailingSpaces(testRootPath, minimumMatches: 2), exitCode: 1);
final String lines = <String>[
'test/analyze-test-input/root/packages/foo/spaces.txt:5: trailing U+0020 space character',
'test/analyze-test-input/root/packages/foo/spaces.txt:9: trailing blank line',
]
.map((String line) => line.replaceAll('/', Platform.isWindows ? r'\' : '/'))
.join('\n');
expect(result,
'━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'
+
(
'test/analyze-test-input/root/packages/foo/spaces.txt:5: trailing U+0020 space character\n'
'test/analyze-test-input/root/packages/foo/spaces.txt:9: trailing blank line\n'
.replaceAll('/', Platform.isWindows ? r'\' : '/')
)
+
'$lines\n'
'━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'
);
});

View File

@@ -224,7 +224,7 @@ Future<void> main() async {
section('Build Objective-C application with Swift and Objective-C plugins as frameworks');
objcPodfileContent = 'use_frameworks!\n' + objcPodfileContent;
objcPodfileContent = 'use_frameworks!\n$objcPodfileContent';
objcPodfile.writeAsStringSync(objcPodfileContent, flush: true);
await inDirectory(objcAppPath, () async {

View File

@@ -445,7 +445,7 @@ Future<ProcessResult> _resultOfGradleTask({String workingDirectory, String task,
];
final String gradle = path.join(workingDirectory, Platform.isWindows ? 'gradlew.bat' : './gradlew');
print('┌── $gradle');
print('│ ' + File(path.join(workingDirectory, gradle)).readAsLinesSync().join('\n│ '));
print(File(path.join(workingDirectory, gradle)).readAsLinesSync().map((String line) => '| $line').join('\n'));
print('└─────────────────────────────────────────────────────────────────────────────────────');
print(
'Running Gradle:\n'

View File

@@ -126,7 +126,7 @@ class Cocoon {
if (resultFile.existsSync()) {
resultFile.deleteSync();
}
logger.fine('Writing results: ' + json.encode(updateRequest));
logger.fine('Writing results: ${json.encode(updateRequest)}');
resultFile.createSync();
resultFile.writeAsStringSync(json.encode(updateRequest));
}

View File

@@ -148,7 +148,7 @@ Iterable<RunningProcessInfo> processPowershellOutput(String output) sync* {
rawTime = '0$rawTime';
}
if (rawTime[4] == '/') {
rawTime = rawTime.substring(0, 3) + '0' + rawTime.substring(3);
rawTime = '${rawTime.substring(0, 3)}0${rawTime.substring(3)}';
}
final String year = rawTime.substring(6, 10);
final String month = rawTime.substring(3, 5);

View File

@@ -564,7 +564,8 @@ T requireConfigProperty<T>(Map<String, dynamic> map, String propertyName) {
}
String jsonEncode(dynamic data) {
return const JsonEncoder.withIndent(' ').convert(data) + '\n';
final String jsonValue = const JsonEncoder.withIndent(' ').convert(data);
return '$jsonValue\n';
}
Future<void> getNewGallery(String revision, Directory galleryDir) async {

View File

@@ -95,7 +95,7 @@ TaskFunction createHotModeTest({String deviceIdOverride, Map<String, String> env
if (hotReloadCount == 2) {
// Trigger a framework invalidation (370 libraries) without modifying the source
flutterFrameworkSource.writeAsStringSync(
flutterFrameworkSource.readAsStringSync() + '\n'
'${flutterFrameworkSource.readAsStringSync()}\n'
);
process.stdin.writeln('r');
hotReloadCount += 1;

View File

@@ -1004,7 +1004,7 @@ class WebCompileTest {
sizeMetrics['${metric}_dart2js_size'] = _parseDu(result.stdout as String);
await Process.run('gzip',<String>['-k', '9', fileName]);
final ProcessResult resultGzip = await Process.run('du', <String>['-k', fileName + '.gz']);
final ProcessResult resultGzip = await Process.run('du', <String>['-k', '$fileName.gz']);
sizeMetrics['${metric}_dart2js_size_gzip'] = _parseDu(resultGzip.stdout as String);
return sizeMetrics;

View File

@@ -217,7 +217,7 @@ void main() {
test('reads token from service account file with whitespace', () {
final File serviceAccountFile = fs.file(serviceAccountTokenPath)..createSync();
serviceAccountFile.writeAsStringSync(serviceAccountToken + ' \n');
serviceAccountFile.writeAsStringSync('$serviceAccountToken \n');
final AuthenticatedCocoonClient client = AuthenticatedCocoonClient(serviceAccountTokenPath, filesystem: fs);
expect(client.serviceAccountToken, serviceAccountToken);
});

View File

@@ -36,9 +36,9 @@ class FloatToken extends NumberToken {
static double _parse(String stringRep) {
String toParse = stringRep;
if (toParse.startsWith('.'))
toParse = '0' + toParse;
toParse = '0$toParse';
if (toParse.endsWith('.'))
toParse = toParse + '0';
toParse = '${toParse}0';
return double.parse(toParse);
}
}
@@ -189,7 +189,8 @@ class CalcExpression {
case ExpressionState.LeadingNeg:
case ExpressionState.Number:
final ExpressionToken last = outList.removeLast()!;
newToken = FloatToken(last.stringRep! + '.');
final String value = last.stringRep!;
newToken = FloatToken('$value.');
break;
case ExpressionState.Point:
case ExpressionState.NumberWithPoint:

View File

@@ -220,7 +220,8 @@ class _ChipDemoState extends State<ChipDemo> {
if (_selectedAction.isEmpty) {
return '';
}
return _capitalize(_results[_selectedAction]!) + '!';
final String value = _capitalize(_results[_selectedAction]!);
return '$value!';
}
@override

View File

@@ -317,17 +317,20 @@ class _UsNumberTextInputFormatter extends TextInputFormatter {
selectionIndex++;
}
if (newTextLength >= 4) {
newText.write(newValue.text.substring(0, usedSubstringIndex = 3) + ') ');
final String value = newValue.text.substring(0, usedSubstringIndex = 3);
newText.write('$value) ');
if (newValue.selection.end >= 3)
selectionIndex += 2;
}
if (newTextLength >= 7) {
newText.write(newValue.text.substring(3, usedSubstringIndex = 6) + '-');
final String value = newValue.text.substring(3, usedSubstringIndex = 6);
newText.write('$value-');
if (newValue.selection.end >= 6)
selectionIndex++;
}
if (newTextLength >= 11) {
newText.write(newValue.text.substring(6, usedSubstringIndex = 10) + ' ');
final String value = newValue.text.substring(6, usedSubstringIndex = 10);
newText.write('$value ');
if (newValue.selection.end >= 10)
selectionIndex++;
}

View File

@@ -457,7 +457,8 @@ class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin {
case 65: // random emoji
return String.fromCharCode(0x1F000 + _random.nextInt(0x9FF));
case 66:
return 'Z{' + zalgo(_random, _random.nextInt(4) + 2) + '}Z';
final String value = zalgo(_random, _random.nextInt(4) + 2);
return 'Z{$value}Z';
case 67:
return 'Οὐχὶ ταὐτὰ παρίσταταί μοι γιγνώσκειν';
case 68:
@@ -963,7 +964,10 @@ class _PaintingState extends State<Painting> with SingleTickerProviderStateMixin
if (mounted && intrinsicKey.currentContext?.size?.height != controlKey.currentContext?.size?.height) {
debugPrint('Found some text that unexpectedly renders at different heights.');
debugPrint('Text: $_text');
debugPrint(_text?.runes.map<String>((int index) => 'U+' + index.toRadixString(16).padLeft(4, '0')).join(' '));
debugPrint(_text?.runes.map<String>((int index) {
final String hexa = index.toRadixString(16).padLeft(4, '0');
return 'U+$hexa';
}).join(' '));
setState(() {
_ticker.stop();
});

View File

@@ -185,8 +185,10 @@ Future<void> main(List<String> rawArguments) async {
// Write data files
const JsonEncoder encoder = JsonEncoder.withIndent(' ');
File(parsedArguments['physical-data'] as String).writeAsStringSync(encoder.convert(physicalData.toJson()) + '\n');
File(parsedArguments['logical-data'] as String).writeAsStringSync(encoder.convert(logicalData.toJson()) + '\n');
final String physicalJson = encoder.convert(physicalData.toJson());
File(parsedArguments['physical-data'] as String).writeAsStringSync('$physicalJson\n');
final String logicalJson = encoder.convert(logicalData.toJson());
File(parsedArguments['logical-data'] as String).writeAsStringSync('$logicalJson\n');
} else {
physicalData = PhysicalKeyData.fromJson(json.decode(await File(parsedArguments['physical-data'] as String).readAsString()) as Map<String, dynamic>);
logicalData = LogicalKeyData.fromJson(json.decode(await File(parsedArguments['logical-data'] as String).readAsString()) as Map<String, dynamic>);

View File

@@ -37,7 +37,7 @@ Future<Archive?> fetchArchive(String url, int maxTries) async {
// On failure print a short snipped from the body in case it's helpful.
final int bodyLength = min(1024, response.body.length);
stderr.writeln('Response status code ${response.statusCode}. Body: ' + response.body.substring(0, bodyLength));
stderr.writeln('Response status code ${response.statusCode}. Body: ${response.body.substring(0, bodyLength)}');
sleep(const Duration(seconds: 1));
}
return responseBytes == null ? null : ZipDecoder().decodeBytes(responseBytes);

View File

@@ -95,7 +95,7 @@ String generateArbBasedLocalizationSubclasses({
languageToScriptCodes[locale.languageCode].add(locale.scriptCode);
}
if (locale.countryCode != null && locale.scriptCode != null) {
final LocaleInfo key = LocaleInfo.fromString(locale.languageCode + '_' + locale.scriptCode);
final LocaleInfo key = LocaleInfo.fromString('${locale.languageCode}_${locale.scriptCode}');
languageAndScriptToCountryCodes[key] ??= <String>{};
languageAndScriptToCountryCodes[key].add(locale.countryCode);
}
@@ -150,7 +150,7 @@ String generateArbBasedLocalizationSubclasses({
// Language has scriptCodes, so we need to properly fallback countries to corresponding
// script default values before language default values.
for (final String scriptCode in languageToScriptCodes[languageName]) {
final LocaleInfo scriptBaseLocale = LocaleInfo.fromString(languageName + '_' + scriptCode);
final LocaleInfo scriptBaseLocale = LocaleInfo.fromString('${languageName}_$scriptCode');
output.writeln(generateClassDeclaration(
scriptBaseLocale,
generatedClassPrefix,
@@ -170,7 +170,7 @@ String generateArbBasedLocalizationSubclasses({
for (final LocaleInfo locale in localeCodes) {
if (locale.originalString == languageName)
continue;
if (locale.originalString == languageName + '_' + scriptCode)
if (locale.originalString == '${languageName}_$scriptCode')
continue;
if (locale.scriptCode != scriptCode)
continue;
@@ -217,12 +217,12 @@ String generateArbBasedLocalizationSubclasses({
}
}
final String scriptCodeMessage = scriptCodeCount == 0 ? '' : ' and $scriptCodeCount script' + (scriptCodeCount == 1 ? '' : 's');
final String scriptCodeMessage = scriptCodeCount == 0 ? '' : ' and $scriptCodeCount script${scriptCodeCount == 1 ? '' : 's'}';
if (countryCodeCount == 0) {
if (scriptCodeCount == 0)
supportedLocales.writeln('/// * `$languageName` - ${describeLocale(languageName)}');
else
supportedLocales.writeln('/// * `$languageName` - ${describeLocale(languageName)} (plus $scriptCodeCount script' + (scriptCodeCount == 1 ? '' : 's') + ')');
supportedLocales.writeln('/// * `$languageName` - ${describeLocale(languageName)} (plus $scriptCodeCount script${scriptCodeCount == 1 ? '' : 's'})');
} else if (countryCodeCount == 1) {
supportedLocales.writeln('/// * `$languageName` - ${describeLocale(languageName)} (plus one country variation$scriptCodeMessage)');
@@ -295,7 +295,7 @@ $factoryDeclaration
case '$language': {
switch (locale.scriptCode) {''');
for (final String scriptCode in languageToScriptCodes[language]) {
final LocaleInfo scriptLocale = LocaleInfo.fromString(language + '_' + scriptCode);
final LocaleInfo scriptLocale = LocaleInfo.fromString('${language}_$scriptCode');
output.writeln('''
case '$scriptCode': {''');
if (languageAndScriptToCountryCodes.containsKey(scriptLocale)) {
@@ -458,7 +458,7 @@ String generateValue(String value, Map<String, dynamic> attributes, LocaleInfo l
throw Exception(
'"$value" is not one of the ICU short time patterns supported '
'by the material library. Here is the list of supported '
'patterns:\n ' + _icuTimeOfDayToEnum.keys.join('\n ')
'patterns:\n ${_icuTimeOfDayToEnum.keys.join('\n ')}'
);
}
return _icuTimeOfDayToEnum[value];
@@ -467,7 +467,7 @@ String generateValue(String value, Map<String, dynamic> attributes, LocaleInfo l
throw Exception(
'"$value" is not one of the scriptCategory values supported '
'by the material library. Here is the list of supported '
'values:\n ' + _scriptCategoryToEnum.keys.join('\n ')
'values:\n ${_scriptCategoryToEnum.keys.join('\n ')}'
);
}
return _scriptCategoryToEnum[value];

View File

@@ -96,9 +96,9 @@ class LocaleInfo implements Comparable<LocaleInfo> {
// Update the base string to reflect assumed scriptCodes.
originalString = languageCode;
if (scriptCode != null)
originalString += '_' + scriptCode;
originalString += '_$scriptCode';
if (countryCode != null)
originalString += '_' + countryCode;
originalString += '_$countryCode';
}
return LocaleInfo(
@@ -202,7 +202,7 @@ void loadMatchingArbsIntoBundleMaps({
// Add an assumed locale to default to when there is no info on scriptOnly locales.
locale = LocaleInfo.fromString(localeString, deriveScriptCode: true);
if (locale.scriptCode != null) {
final LocaleInfo scriptLocale = LocaleInfo.fromString(locale.languageCode + '_' + locale.scriptCode);
final LocaleInfo scriptLocale = LocaleInfo.fromString('${locale.languageCode}_${locale.scriptCode}');
if (!localeToResources.containsKey(scriptLocale)) {
assumedLocales.add(scriptLocale);
localeToResources[scriptLocale] ??= <String, String>{};

View File

@@ -192,6 +192,6 @@ int _lineCount(File file) {
String _comma(int count) {
final String str = count.toString();
if (str.length > 3)
return str.substring(0, str.length - 3) + ',' + str.substring(str.length - 3);
return '${str.substring(0, str.length - 3)},${str.substring(str.length - 3)}';
return str;
}