[flutter_tools] Fix tool crash for map cast (#107648)
This commit is contained in:
@@ -61,9 +61,9 @@ class GenerateLocalizationsTarget extends Target {
|
||||
fileSystem: environment.fileSystem,
|
||||
);
|
||||
|
||||
final Map<String, Object> dependencies = json.decode(
|
||||
final Map<String, Object?> dependencies = json.decode(
|
||||
environment.buildDir.childFile(_kDependenciesFileName).readAsStringSync()
|
||||
) as Map<String, Object>;
|
||||
) as Map<String, Object?>;
|
||||
final List<Object?>? inputs = dependencies['inputs'] as List<Object?>?;
|
||||
final List<Object?>? outputs = dependencies['outputs'] as List<Object?>?;
|
||||
final Depfile depfile = Depfile(
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/commands/packages.dart';
|
||||
import 'package:flutter_tools/src/dart/pub.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:flutter_tools/src/runner/flutter_command.dart';
|
||||
import 'package:test/fake.dart';
|
||||
|
||||
import '../../src/context.dart';
|
||||
@@ -112,6 +113,52 @@ void main() {
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
FileSystem: () => fileSystem,
|
||||
});
|
||||
|
||||
testUsingContext('pub get triggers localizations generation when generate: true', () async {
|
||||
final File pubspecFile = fileSystem.currentDirectory.childFile('pubspec.yaml')
|
||||
..createSync();
|
||||
pubspecFile.writeAsStringSync(
|
||||
'''
|
||||
flutter:
|
||||
generate: true
|
||||
'''
|
||||
);
|
||||
fileSystem.currentDirectory.childFile('l10n.yaml')
|
||||
..createSync()
|
||||
..writeAsStringSync(
|
||||
'''
|
||||
arb-dir: lib/l10n
|
||||
'''
|
||||
);
|
||||
final File arbFile = fileSystem.file(fileSystem.path.join('lib', 'l10n', 'app_en.arb'))
|
||||
..createSync(recursive: true);
|
||||
arbFile.writeAsStringSync(
|
||||
'''
|
||||
{
|
||||
"helloWorld": "Hello, World!",
|
||||
"@helloWorld": {
|
||||
"description": "Sample description"
|
||||
}
|
||||
}
|
||||
'''
|
||||
);
|
||||
|
||||
final PackagesGetCommand command = PackagesGetCommand('get', false);
|
||||
final CommandRunner<void> commandRunner = createTestCommandRunner(command);
|
||||
|
||||
await commandRunner.run(<String>['get']);
|
||||
final FlutterCommandResult result = await command.runCommand();
|
||||
|
||||
expect(result.exitStatus, ExitStatus.success);
|
||||
final Directory outputDirectory = fileSystem.directory(fileSystem.path.join('.dart_tool', 'flutter_gen', 'gen_l10n'));
|
||||
expect(outputDirectory.existsSync(), true);
|
||||
expect(outputDirectory.childFile('app_localizations_en.dart').existsSync(), true);
|
||||
expect(outputDirectory.childFile('app_localizations.dart').existsSync(), true);
|
||||
}, overrides: <Type, Generator>{
|
||||
Pub: () => pub,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
FileSystem: () => fileSystem,
|
||||
});
|
||||
}
|
||||
|
||||
class FakePub extends Fake implements Pub {
|
||||
|
||||
Reference in New Issue
Block a user