mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Declare locals as final where not reassigned (dev) (#8574)
This commit is contained in:
parent
7a52fb6772
commit
6c97dd2c6c
@ -449,7 +449,7 @@ class ItemGalleryBox extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<String> tabNames = <String>[
|
||||
final List<String> tabNames = <String>[
|
||||
'A', 'B', 'C', 'D'
|
||||
];
|
||||
|
||||
|
@ -20,9 +20,9 @@ void main() {
|
||||
});
|
||||
|
||||
test('measure', () async {
|
||||
Timeline timeline = await driver.traceAction(() async {
|
||||
final Timeline timeline = await driver.traceAction(() async {
|
||||
// Find the scrollable stock list
|
||||
SerializableFinder stockList = find.byValueKey('main-scroll');
|
||||
final SerializableFinder stockList = find.byValueKey('main-scroll');
|
||||
expect(stockList, isNotNull);
|
||||
|
||||
// Scroll down
|
||||
@ -38,7 +38,7 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
TimelineSummary summary = new TimelineSummary.summarize(timeline);
|
||||
final TimelineSummary summary = new TimelineSummary.summarize(timeline);
|
||||
summary.writeSummaryToFile('complex_layout_scroll_perf', pretty: true);
|
||||
summary.writeTimelineToFile('complex_layout_scroll_perf', pretty: true);
|
||||
});
|
||||
|
@ -54,7 +54,7 @@ class BenchmarkResultPrinter {
|
||||
}
|
||||
|
||||
String _printPlainText() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
final StringBuffer buf = new StringBuffer();
|
||||
for (_BenchmarkResult result in _results) {
|
||||
buf.writeln('${result.description}: ${result.value.toStringAsFixed(1)} ${result.unit}');
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ void main() {
|
||||
}
|
||||
watch.stop();
|
||||
|
||||
BenchmarkResultPrinter printer = new BenchmarkResultPrinter();
|
||||
final BenchmarkResultPrinter printer = new BenchmarkResultPrinter();
|
||||
printer.addResult(
|
||||
description: 'Velocity tracker',
|
||||
value: watch.elapsedMicroseconds / _kNumIters,
|
||||
|
@ -75,7 +75,7 @@ Future<Null> main() async {
|
||||
}
|
||||
});
|
||||
|
||||
BenchmarkResultPrinter printer = new BenchmarkResultPrinter();
|
||||
final BenchmarkResultPrinter printer = new BenchmarkResultPrinter();
|
||||
printer.addResult(
|
||||
description: 'Stock animation',
|
||||
value: wallClockWatch.elapsedMicroseconds / (1000 * 1000),
|
||||
|
@ -21,7 +21,7 @@ Future<Null> main() async {
|
||||
|
||||
// This allows us to call onBeginFrame even when the engine didn't request it,
|
||||
// and have it actually do something:
|
||||
LiveTestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final LiveTestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
binding.allowAllFrames = true;
|
||||
|
||||
final Stopwatch watch = new Stopwatch();
|
||||
@ -50,7 +50,7 @@ Future<Null> main() async {
|
||||
watch.stop();
|
||||
});
|
||||
|
||||
BenchmarkResultPrinter printer = new BenchmarkResultPrinter();
|
||||
final BenchmarkResultPrinter printer = new BenchmarkResultPrinter();
|
||||
printer.addResult(
|
||||
description: 'Stock build',
|
||||
value: watch.elapsedMicroseconds / iterations,
|
||||
|
@ -20,7 +20,7 @@ Future<Null> main() async {
|
||||
|
||||
// This allows us to call onBeginFrame even when the engine didn't request it,
|
||||
// and have it actually do something:
|
||||
LiveTestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final LiveTestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
binding.allowAllFrames = true;
|
||||
|
||||
final Stopwatch watch = new Stopwatch();
|
||||
@ -51,7 +51,7 @@ Future<Null> main() async {
|
||||
watch.stop();
|
||||
});
|
||||
|
||||
BenchmarkResultPrinter printer = new BenchmarkResultPrinter();
|
||||
final BenchmarkResultPrinter printer = new BenchmarkResultPrinter();
|
||||
printer.addResult(
|
||||
description: 'Stock layout',
|
||||
value: watch.elapsedMicroseconds / iterations,
|
||||
|
@ -31,7 +31,7 @@ Future<Null> main() async {
|
||||
print('\x1B[32mDONE: Analysis successful.\x1B[0m');
|
||||
} else {
|
||||
// Verify that the tests actually return failure on failure and success on success.
|
||||
String automatedTests = p.join(flutterRoot, 'dev', 'automated_tests');
|
||||
final String automatedTests = p.join(flutterRoot, 'dev', 'automated_tests');
|
||||
await _runFlutterTest(automatedTests,
|
||||
script: p.join('test_smoke_test', 'fail_test.dart'),
|
||||
expectFailure: true,
|
||||
@ -67,7 +67,7 @@ Future<Null> main() async {
|
||||
printOutput: false,
|
||||
);
|
||||
|
||||
List<String> coverageFlags = <String>[];
|
||||
final List<String> coverageFlags = <String>[];
|
||||
if (Platform.environment['TRAVIS'] != null && Platform.environment['TRAVIS_PULL_REQUEST'] == 'false')
|
||||
coverageFlags.add('--coverage');
|
||||
|
||||
@ -100,15 +100,15 @@ Future<Null> _runCmd(String executable, List<String> arguments, {
|
||||
bool printOutput: true,
|
||||
bool skip: false,
|
||||
}) async {
|
||||
String cmd = '${p.relative(executable)} ${arguments.join(' ')}';
|
||||
String relativeWorkingDir = p.relative(workingDirectory);
|
||||
final String cmd = '${p.relative(executable)} ${arguments.join(' ')}';
|
||||
final String relativeWorkingDir = p.relative(workingDirectory);
|
||||
if (skip) {
|
||||
_printProgress('SKIPPING', relativeWorkingDir, cmd);
|
||||
return null;
|
||||
}
|
||||
_printProgress('RUNNING', relativeWorkingDir, cmd);
|
||||
|
||||
Process process = await Process.start(executable, arguments,
|
||||
final Process process = await Process.start(executable, arguments,
|
||||
workingDirectory: workingDirectory,
|
||||
environment: environment,
|
||||
);
|
||||
@ -118,7 +118,7 @@ Future<Null> _runCmd(String executable, List<String> arguments, {
|
||||
stderr.addStream(process.stderr);
|
||||
}
|
||||
|
||||
int exitCode = await process.exitCode;
|
||||
final int exitCode = await process.exitCode;
|
||||
if ((exitCode == 0) == expectFailure) {
|
||||
print(
|
||||
'\x1B[31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\x1B[0m\n'
|
||||
@ -136,7 +136,7 @@ Future<Null> _runFlutterTest(String workingDirectory, {
|
||||
List<String> options: const <String>[],
|
||||
bool skip: false,
|
||||
}) {
|
||||
List<String> args = <String>['test']..addAll(options);
|
||||
final List<String> args = <String>['test']..addAll(options);
|
||||
if (flutterTestArgs != null)
|
||||
args.add(flutterTestArgs);
|
||||
if (script != null)
|
||||
@ -152,7 +152,7 @@ Future<Null> _runFlutterTest(String workingDirectory, {
|
||||
Future<Null> _runAllDartTests(String workingDirectory, {
|
||||
Map<String, String> environment,
|
||||
}) {
|
||||
List<String> args = <String>['--checked', p.join('test', 'all.dart')];
|
||||
final List<String> args = <String>['--checked', p.join('test', 'all.dart')];
|
||||
return _runCmd(dart, args,
|
||||
workingDirectory: workingDirectory,
|
||||
environment: environment,
|
||||
|
@ -33,14 +33,14 @@ Future<Null> main(List<String> rawArgs) async {
|
||||
|
||||
if (!args.wasParsed('task')) {
|
||||
if (args.wasParsed('stage')) {
|
||||
String stageName = args['stage'];
|
||||
List<ManifestTask> tasks = loadTaskManifest().tasks;
|
||||
final String stageName = args['stage'];
|
||||
final List<ManifestTask> tasks = loadTaskManifest().tasks;
|
||||
for (ManifestTask task in tasks) {
|
||||
if (task.stage == stageName)
|
||||
_taskNames.add(task.name);
|
||||
}
|
||||
} else if (args.wasParsed('all')) {
|
||||
List<ManifestTask> tasks = loadTaskManifest().tasks;
|
||||
final List<ManifestTask> tasks = loadTaskManifest().tasks;
|
||||
for (ManifestTask task in tasks) {
|
||||
_taskNames.add(task.name);
|
||||
}
|
||||
@ -53,11 +53,11 @@ Future<Null> main(List<String> rawArgs) async {
|
||||
return null;
|
||||
}
|
||||
|
||||
bool silent = args['silent'];
|
||||
final bool silent = args['silent'];
|
||||
|
||||
for (String taskName in _taskNames) {
|
||||
section('Running task "$taskName"');
|
||||
Map<String, dynamic> result = await runTask(taskName, silent: silent);
|
||||
final Map<String, dynamic> result = await runTask(taskName, silent: silent);
|
||||
|
||||
if (!result['success'])
|
||||
exitCode = 1;
|
||||
@ -82,8 +82,8 @@ final ArgParser _argParser = new ArgParser()
|
||||
'This option may be repeated to specify multiple tasks.',
|
||||
callback: (List<String> value) {
|
||||
for (String nameOrPath in value) {
|
||||
List<String> fragments = path.split(nameOrPath);
|
||||
bool isDartFile = fragments.last.endsWith('.dart');
|
||||
final List<String> fragments = path.split(nameOrPath);
|
||||
final bool isDartFile = fragments.last.endsWith('.dart');
|
||||
|
||||
if (fragments.length == 1 && !isDartFile) {
|
||||
// Not a path
|
||||
|
@ -9,9 +9,9 @@ import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
|
||||
Future<Null> main() async {
|
||||
String revision = await getCurrentFlutterRepoCommit();
|
||||
DateTime revisionTimestamp = await getFlutterRepoCommitTimestamp(revision);
|
||||
String dartSdkVersion = await getDartVersion();
|
||||
final String revision = await getCurrentFlutterRepoCommit();
|
||||
final DateTime revisionTimestamp = await getFlutterRepoCommitTimestamp(revision);
|
||||
final String dartSdkVersion = await getDartVersion();
|
||||
await task(createAnalyzerCliTest(
|
||||
sdk: dartSdkVersion,
|
||||
commit: revision,
|
||||
|
@ -9,9 +9,9 @@ import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
|
||||
Future<Null> main() async {
|
||||
String revision = await getCurrentFlutterRepoCommit();
|
||||
DateTime revisionTimestamp = await getFlutterRepoCommitTimestamp(revision);
|
||||
String dartSdkVersion = await getDartVersion();
|
||||
final String revision = await getCurrentFlutterRepoCommit();
|
||||
final DateTime revisionTimestamp = await getFlutterRepoCommitTimestamp(revision);
|
||||
final String dartSdkVersion = await getDartVersion();
|
||||
await task(createAnalyzerServerTest(
|
||||
sdk: dartSdkVersion,
|
||||
commit: revision,
|
||||
|
@ -12,11 +12,11 @@ import 'package:flutter_devicelab/framework/utils.dart';
|
||||
|
||||
void main() {
|
||||
task(() async {
|
||||
Device device = await devices.workingDevice;
|
||||
final Device device = await devices.workingDevice;
|
||||
await device.unlock();
|
||||
Directory appDir =
|
||||
final Directory appDir =
|
||||
dir(path.join(flutterDirectory.path, 'examples/flutter_gallery'));
|
||||
File benchmarkFile = file(path.join(appDir.path, 'hot_benchmark.json'));
|
||||
final File benchmarkFile = file(path.join(appDir.path, 'hot_benchmark.json'));
|
||||
rm(benchmarkFile);
|
||||
await inDirectory(appDir, () async {
|
||||
return await flutter('run',
|
||||
|
@ -39,7 +39,7 @@ const String _kBenchmarkKey = 'technical_debt_in_dollars';
|
||||
|
||||
Future<Null> main() async {
|
||||
await task(() async {
|
||||
Process git = await startProcess(
|
||||
final Process git = await startProcess(
|
||||
'git',
|
||||
<String>['ls-files', '--full-name', flutterDirectory.path],
|
||||
workingDirectory: flutterDirectory.path,
|
||||
@ -47,7 +47,7 @@ Future<Null> main() async {
|
||||
double total = 0.0;
|
||||
await for (String entry in git.stdout.transform(UTF8.decoder).transform(const LineSplitter()))
|
||||
total += await findCostsForFile(new File(path.join(flutterDirectory.path, entry)));
|
||||
int gitExitCode = await git.exitCode;
|
||||
final int gitExitCode = await git.exitCode;
|
||||
if (gitExitCode != 0)
|
||||
throw new Exception('git exit with unexpected error code $gitExitCode');
|
||||
return new TaskResult.success(
|
||||
|
@ -118,7 +118,7 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
/// [workingDevice].
|
||||
@override
|
||||
Future<Null> chooseWorkingDevice() async {
|
||||
List<Device> allDevices = (await discoverDevices())
|
||||
final List<Device> allDevices = (await discoverDevices())
|
||||
.map((String id) => new AndroidDevice(deviceId: id))
|
||||
.toList();
|
||||
|
||||
@ -131,9 +131,9 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
|
||||
@override
|
||||
Future<List<String>> discoverDevices() async {
|
||||
List<String> output = (await eval(adbPath, <String>['devices', '-l'], canFail: false))
|
||||
final List<String> output = (await eval(adbPath, <String>['devices', '-l'], canFail: false))
|
||||
.trim().split('\n');
|
||||
List<String> results = <String>[];
|
||||
final List<String> results = <String>[];
|
||||
for (String line in output) {
|
||||
// Skip lines like: * daemon started successfully *
|
||||
if (line.startsWith('* daemon '))
|
||||
@ -143,10 +143,10 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
continue;
|
||||
|
||||
if (_kDeviceRegex.hasMatch(line)) {
|
||||
Match match = _kDeviceRegex.firstMatch(line);
|
||||
final Match match = _kDeviceRegex.firstMatch(line);
|
||||
|
||||
String deviceID = match[1];
|
||||
String deviceState = match[2];
|
||||
final String deviceID = match[1];
|
||||
final String deviceState = match[2];
|
||||
|
||||
if (!const <String>['unauthorized', 'offline'].contains(deviceState)) {
|
||||
results.add(deviceID);
|
||||
@ -161,10 +161,10 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
|
||||
|
||||
@override
|
||||
Future<Map<String, HealthCheckResult>> checkDevices() async {
|
||||
Map<String, HealthCheckResult> results = <String, HealthCheckResult>{};
|
||||
final Map<String, HealthCheckResult> results = <String, HealthCheckResult>{};
|
||||
for (String deviceId in await discoverDevices()) {
|
||||
try {
|
||||
AndroidDevice device = new AndroidDevice(deviceId: deviceId);
|
||||
final AndroidDevice device = new AndroidDevice(deviceId: deviceId);
|
||||
// Just a smoke test that we can read wakefulness state
|
||||
// TODO(yjbanov): check battery level
|
||||
await device._getWakefulness();
|
||||
@ -240,8 +240,8 @@ class AndroidDevice implements Device {
|
||||
///
|
||||
/// See: https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/os/PowerManagerInternal.java
|
||||
Future<String> _getWakefulness() async {
|
||||
String powerInfo = await shellEval('dumpsys', <String>['power']);
|
||||
String wakefulness = grep('mWakefulness=', from: powerInfo).single.split('=')[1].trim();
|
||||
final String powerInfo = await shellEval('dumpsys', <String>['power']);
|
||||
final String wakefulness = grep('mWakefulness=', from: powerInfo).single.split('=')[1].trim();
|
||||
return wakefulness;
|
||||
}
|
||||
|
||||
@ -257,8 +257,8 @@ class AndroidDevice implements Device {
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> getMemoryStats(String packageName) async {
|
||||
String meminfo = await shellEval('dumpsys', <String>['meminfo', packageName]);
|
||||
Match match = new RegExp(r'TOTAL\s+(\d+)').firstMatch(meminfo);
|
||||
final String meminfo = await shellEval('dumpsys', <String>['meminfo', packageName]);
|
||||
final Match match = new RegExp(r'TOTAL\s+(\d+)').firstMatch(meminfo);
|
||||
return <String, dynamic>{
|
||||
'total_kb': int.parse(match.group(1)),
|
||||
};
|
||||
@ -295,7 +295,7 @@ class IosDeviceDiscovery implements DeviceDiscovery {
|
||||
/// [workingDevice].
|
||||
@override
|
||||
Future<Null> chooseWorkingDevice() async {
|
||||
List<IosDevice> allDevices = (await discoverDevices())
|
||||
final List<IosDevice> allDevices = (await discoverDevices())
|
||||
.map((String id) => new IosDevice(deviceId: id))
|
||||
.toList();
|
||||
|
||||
@ -309,7 +309,7 @@ class IosDeviceDiscovery implements DeviceDiscovery {
|
||||
@override
|
||||
Future<List<String>> discoverDevices() async {
|
||||
// TODO: use the -k UniqueDeviceID option, which requires much less parsing.
|
||||
List<String> iosDeviceIds = grep('UniqueDeviceID', from: await eval('ideviceinfo', <String>[]))
|
||||
final List<String> iosDeviceIds = grep('UniqueDeviceID', from: await eval('ideviceinfo', <String>[]))
|
||||
.map((String line) => line.split(' ').last).toList();
|
||||
|
||||
if (iosDeviceIds.isEmpty)
|
||||
@ -320,7 +320,7 @@ class IosDeviceDiscovery implements DeviceDiscovery {
|
||||
|
||||
@override
|
||||
Future<Map<String, HealthCheckResult>> checkDevices() async {
|
||||
Map<String, HealthCheckResult> results = <String, HealthCheckResult>{};
|
||||
final Map<String, HealthCheckResult> results = <String, HealthCheckResult>{};
|
||||
for (String deviceId in await discoverDevices()) {
|
||||
// TODO: do a more meaningful connectivity check than just recording the ID
|
||||
results['ios-device-$deviceId'] = new HealthCheckResult.success();
|
||||
@ -376,13 +376,13 @@ class IosDevice implements Device {
|
||||
|
||||
/// Path to the `adb` executable.
|
||||
String get adbPath {
|
||||
String androidHome = Platform.environment['ANDROID_HOME'];
|
||||
final String androidHome = Platform.environment['ANDROID_HOME'];
|
||||
|
||||
if (androidHome == null)
|
||||
throw 'ANDROID_HOME environment variable missing. This variable must '
|
||||
'point to the Android SDK directory containing platform-tools.';
|
||||
|
||||
File adbPath = file(path.join(androidHome, 'platform-tools/adb'));
|
||||
final File adbPath = file(path.join(androidHome, 'platform-tools/adb'));
|
||||
|
||||
if (!adbPath.existsSync()) throw 'adb not found at: $adbPath';
|
||||
|
||||
|
@ -33,7 +33,7 @@ Future<num> runBenchmark(Benchmark benchmark, {
|
||||
}) async {
|
||||
await benchmark.init();
|
||||
|
||||
List<num> allRuns = <num>[];
|
||||
final List<num> allRuns = <num>[];
|
||||
|
||||
num minValue;
|
||||
|
||||
@ -46,7 +46,7 @@ Future<num> runBenchmark(Benchmark benchmark, {
|
||||
print('');
|
||||
|
||||
try {
|
||||
num result = await benchmark.run();
|
||||
final num result = await benchmark.run();
|
||||
allRuns.add(result);
|
||||
|
||||
if (minValue == null || result < minValue) {
|
||||
|
@ -43,7 +43,7 @@ Future<TaskResult> task(TaskFunction task) {
|
||||
print('${rec.level.name}: ${rec.time}: ${rec.message}');
|
||||
});
|
||||
|
||||
_TaskRunner runner = new _TaskRunner(task);
|
||||
final _TaskRunner runner = new _TaskRunner(task);
|
||||
runner.keepVmAliveUntilTaskRunRequested();
|
||||
return runner.whenDone;
|
||||
}
|
||||
@ -63,7 +63,7 @@ class _TaskRunner {
|
||||
_TaskRunner(this.task) {
|
||||
registerExtension('ext.cocoonRunTask',
|
||||
(String method, Map<String, String> parameters) async {
|
||||
TaskResult result = await run();
|
||||
final TaskResult result = await run();
|
||||
return new ServiceExtensionResponse.result(JSON.encode(result.toJson()));
|
||||
});
|
||||
registerExtension('ext.cocoonRunnerReady',
|
||||
@ -78,7 +78,7 @@ class _TaskRunner {
|
||||
Future<TaskResult> run() async {
|
||||
try {
|
||||
_taskStarted = true;
|
||||
TaskResult result = await _performTask().timeout(taskTimeout);
|
||||
final TaskResult result = await _performTask().timeout(taskTimeout);
|
||||
_completer.complete(result);
|
||||
return result;
|
||||
} on TimeoutException catch (_) {
|
||||
@ -117,11 +117,11 @@ class _TaskRunner {
|
||||
}
|
||||
|
||||
Future<TaskResult> _performTask() {
|
||||
Completer<TaskResult> completer = new Completer<TaskResult>();
|
||||
final Completer<TaskResult> completer = new Completer<TaskResult>();
|
||||
Chain.capture(() async {
|
||||
completer.complete(await task());
|
||||
}, onError: (dynamic taskError, Chain taskErrorStack) {
|
||||
String message = 'Task failed: $taskError';
|
||||
final String message = 'Task failed: $taskError';
|
||||
stderr
|
||||
..writeln(message)
|
||||
..writeln('\nStack trace:')
|
||||
@ -210,7 +210,7 @@ class TaskResult {
|
||||
/// "reason": failure reason string valid only for unsuccessful results
|
||||
/// }
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, dynamic> json = <String, dynamic>{
|
||||
final Map<String, dynamic> json = <String, dynamic>{
|
||||
'success': succeeded,
|
||||
};
|
||||
|
||||
|
@ -9,7 +9,7 @@ import 'utils.dart';
|
||||
|
||||
/// Loads manifest data from `manifest.yaml` file or from [yaml], if present.
|
||||
Manifest loadTaskManifest([ String yaml ]) {
|
||||
dynamic manifestYaml = yaml == null
|
||||
final dynamic manifestYaml = yaml == null
|
||||
? loadYaml(file('manifest.yaml').readAsStringSync())
|
||||
: loadYamlNode(yaml);
|
||||
|
||||
@ -33,7 +33,7 @@ class ManifestTask {
|
||||
@required this.stage,
|
||||
@required this.requiredAgentCapabilities,
|
||||
}) {
|
||||
String taskName = 'task "$name"';
|
||||
final String taskName = 'task "$name"';
|
||||
_checkIsNotBlank(name, 'Task name', taskName);
|
||||
_checkIsNotBlank(description, 'Task description', taskName);
|
||||
_checkIsNotBlank(stage, 'Task stage', taskName);
|
||||
@ -84,7 +84,7 @@ ManifestTask _validateAndParseTask(dynamic taskName, dynamic taskYaml) {
|
||||
'required_agent_capabilities',
|
||||
]);
|
||||
|
||||
List<String> capabilities = _validateAndParseCapabilities(taskName, taskYaml['required_agent_capabilities']);
|
||||
final List<String> capabilities = _validateAndParseCapabilities(taskName, taskYaml['required_agent_capabilities']);
|
||||
return new ManifestTask._(
|
||||
name: taskName,
|
||||
description: taskYaml['description'],
|
||||
@ -96,7 +96,7 @@ ManifestTask _validateAndParseTask(dynamic taskName, dynamic taskYaml) {
|
||||
List<String> _validateAndParseCapabilities(String taskName, dynamic capabilitiesYaml) {
|
||||
_checkType(capabilitiesYaml is List, capabilitiesYaml, 'required_agent_capabilities', 'list');
|
||||
for (int i = 0; i < capabilitiesYaml.length; i++) {
|
||||
dynamic capability = capabilitiesYaml[i];
|
||||
final dynamic capability = capabilitiesYaml[i];
|
||||
_checkType(capability is String, capability, 'required_agent_capabilities[$i]', 'string');
|
||||
}
|
||||
return capabilitiesYaml;
|
||||
|
@ -23,13 +23,13 @@ const Duration taskTimeoutWithGracePeriod = const Duration(minutes: 11);
|
||||
/// Running the task in [silent] mode will suppress standard output from task
|
||||
/// processes and only print standard errors.
|
||||
Future<Map<String, dynamic>> runTask(String taskName, { bool silent: false }) async {
|
||||
String taskExecutable = 'bin/tasks/$taskName.dart';
|
||||
final String taskExecutable = 'bin/tasks/$taskName.dart';
|
||||
|
||||
if (!file(taskExecutable).existsSync())
|
||||
throw 'Executable Dart file not found: $taskExecutable';
|
||||
|
||||
int vmServicePort = await findAvailablePort();
|
||||
Process runner = await startProcess(dartBin, <String>[
|
||||
final int vmServicePort = await findAvailablePort();
|
||||
final Process runner = await startProcess(dartBin, <String>[
|
||||
'--enable-vm-service=$vmServicePort',
|
||||
'--no-pause-isolates-on-exit',
|
||||
taskExecutable,
|
||||
@ -41,7 +41,7 @@ Future<Map<String, dynamic>> runTask(String taskName, { bool silent: false }) as
|
||||
runnerFinished = true;
|
||||
});
|
||||
|
||||
StreamSubscription<String> stdoutSub = runner.stdout
|
||||
final StreamSubscription<String> stdoutSub = runner.stdout
|
||||
.transform(const Utf8Decoder())
|
||||
.transform(const LineSplitter())
|
||||
.listen((String line) {
|
||||
@ -50,7 +50,7 @@ Future<Map<String, dynamic>> runTask(String taskName, { bool silent: false }) as
|
||||
}
|
||||
});
|
||||
|
||||
StreamSubscription<String> stderrSub = runner.stderr
|
||||
final StreamSubscription<String> stderrSub = runner.stderr
|
||||
.transform(const Utf8Decoder())
|
||||
.transform(const LineSplitter())
|
||||
.listen((String line) {
|
||||
@ -59,9 +59,9 @@ Future<Map<String, dynamic>> runTask(String taskName, { bool silent: false }) as
|
||||
|
||||
String waitingFor = 'connection';
|
||||
try {
|
||||
VMIsolateRef isolate = await _connectToRunnerIsolate(vmServicePort);
|
||||
final VMIsolateRef isolate = await _connectToRunnerIsolate(vmServicePort);
|
||||
waitingFor = 'task completion';
|
||||
Map<String, dynamic> taskResult =
|
||||
final Map<String, dynamic> taskResult =
|
||||
await isolate.invokeExtension('ext.cocoonRunTask').timeout(taskTimeoutWithGracePeriod);
|
||||
waitingFor = 'task process to exit';
|
||||
await runner.exitCode.timeout(const Duration(seconds: 1));
|
||||
@ -81,8 +81,8 @@ Future<Map<String, dynamic>> runTask(String taskName, { bool silent: false }) as
|
||||
}
|
||||
|
||||
Future<VMIsolateRef> _connectToRunnerIsolate(int vmServicePort) async {
|
||||
String url = 'ws://localhost:$vmServicePort/ws';
|
||||
DateTime started = new DateTime.now();
|
||||
final String url = 'ws://localhost:$vmServicePort/ws';
|
||||
final DateTime started = new DateTime.now();
|
||||
|
||||
// TODO(yjbanov): due to lack of imagination at the moment the handshake with
|
||||
// the task process is very rudimentary and requires this small
|
||||
@ -97,10 +97,10 @@ Future<VMIsolateRef> _connectToRunnerIsolate(int vmServicePort) async {
|
||||
await (await WebSocket.connect(url)).close();
|
||||
|
||||
// Look up the isolate.
|
||||
VMServiceClient client = new VMServiceClient.connect(url);
|
||||
VM vm = await client.getVM();
|
||||
VMIsolateRef isolate = vm.isolates.single;
|
||||
String response = await isolate.invokeExtension('ext.cocoonRunnerReady');
|
||||
final VMServiceClient client = new VMServiceClient.connect(url);
|
||||
final VM vm = await client.getVM();
|
||||
final VMIsolateRef isolate = vm.isolates.single;
|
||||
final String response = await isolate.invokeExtension('ext.cocoonRunnerReady');
|
||||
if (response != 'ready') throw 'not ready yet';
|
||||
return isolate;
|
||||
} catch (error) {
|
||||
|
@ -46,7 +46,7 @@ class HealthCheckResult {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
StringBuffer buf = new StringBuffer(succeeded ? 'succeeded' : 'failed');
|
||||
final StringBuffer buf = new StringBuffer(succeeded ? 'succeeded' : 'failed');
|
||||
if (details != null && details.trim().isNotEmpty) {
|
||||
buf.writeln();
|
||||
// Indent details by 4 spaces
|
||||
@ -89,7 +89,7 @@ Directory dir(String path) => new Directory(path);
|
||||
File file(String path) => new File(path);
|
||||
|
||||
void copy(File sourceFile, Directory targetDirectory, {String name}) {
|
||||
File target = file(
|
||||
final File target = file(
|
||||
path.join(targetDirectory.path, name ?? path.basename(sourceFile.path)));
|
||||
target.writeAsBytesSync(sourceFile.readAsBytesSync());
|
||||
}
|
||||
@ -118,7 +118,7 @@ void section(String title) {
|
||||
|
||||
Future<String> getDartVersion() async {
|
||||
// The Dart VM returns the version text to stderr.
|
||||
ProcessResult result = Process.runSync(dartBin, <String>['--version']);
|
||||
final ProcessResult result = Process.runSync(dartBin, <String>['--version']);
|
||||
String version = result.stderr.trim();
|
||||
|
||||
// Convert:
|
||||
@ -146,13 +146,13 @@ Future<String> getCurrentFlutterRepoCommit() {
|
||||
Future<DateTime> getFlutterRepoCommitTimestamp(String commit) {
|
||||
// git show -s --format=%at 4b546df7f0b3858aaaa56c4079e5be1ba91fbb65
|
||||
return inDirectory(flutterDirectory, () async {
|
||||
String unixTimestamp = await eval('git', <String>[
|
||||
final String unixTimestamp = await eval('git', <String>[
|
||||
'show',
|
||||
'-s',
|
||||
'--format=%at',
|
||||
commit,
|
||||
]);
|
||||
int secondsSinceEpoch = int.parse(unixTimestamp);
|
||||
final int secondsSinceEpoch = int.parse(unixTimestamp);
|
||||
return new DateTime.fromMillisecondsSinceEpoch(secondsSinceEpoch * 1000);
|
||||
});
|
||||
}
|
||||
@ -163,17 +163,17 @@ Future<Process> startProcess(
|
||||
Map<String, String> environment,
|
||||
String workingDirectory,
|
||||
}) async {
|
||||
String command = '$executable ${arguments?.join(" ") ?? ""}';
|
||||
final String command = '$executable ${arguments?.join(" ") ?? ""}';
|
||||
print('Executing: $command');
|
||||
environment ??= <String, String>{};
|
||||
environment['BOT'] = 'true';
|
||||
Process process = await Process.start(
|
||||
final Process process = await Process.start(
|
||||
executable,
|
||||
arguments,
|
||||
environment: environment,
|
||||
workingDirectory: workingDirectory ?? cwd,
|
||||
);
|
||||
ProcessInfo processInfo = new ProcessInfo(command, process);
|
||||
final ProcessInfo processInfo = new ProcessInfo(command, process);
|
||||
_runningProcesses.add(processInfo);
|
||||
|
||||
process.exitCode.whenComplete(() {
|
||||
@ -207,7 +207,7 @@ Future<int> exec(
|
||||
Map<String, String> environment,
|
||||
bool canFail: false,
|
||||
}) async {
|
||||
Process process = await startProcess(executable, arguments, environment: environment);
|
||||
final Process process = await startProcess(executable, arguments, environment: environment);
|
||||
|
||||
process.stdout
|
||||
.transform(UTF8.decoder)
|
||||
@ -218,7 +218,7 @@ Future<int> exec(
|
||||
.transform(const LineSplitter())
|
||||
.listen(stderr.writeln);
|
||||
|
||||
int exitCode = await process.exitCode;
|
||||
final int exitCode = await process.exitCode;
|
||||
|
||||
if (exitCode != 0 && !canFail)
|
||||
fail('Executable failed with exit code $exitCode.');
|
||||
@ -235,12 +235,12 @@ Future<String> eval(
|
||||
Map<String, String> environment,
|
||||
bool canFail: false,
|
||||
}) async {
|
||||
Process process = await startProcess(executable, arguments, environment: environment);
|
||||
final Process process = await startProcess(executable, arguments, environment: environment);
|
||||
process.stderr.listen((List<int> data) {
|
||||
stderr.add(data);
|
||||
});
|
||||
String output = await UTF8.decodeStream(process.stdout);
|
||||
int exitCode = await process.exitCode;
|
||||
final String output = await UTF8.decodeStream(process.stdout);
|
||||
final int exitCode = await process.exitCode;
|
||||
|
||||
if (exitCode != 0 && !canFail)
|
||||
fail('Executable failed with exit code $exitCode.');
|
||||
@ -253,7 +253,7 @@ Future<int> flutter(String command, {
|
||||
bool canFail: false,
|
||||
Map<String, String> environment,
|
||||
}) {
|
||||
List<String> args = <String>[command]..addAll(options);
|
||||
final List<String> args = <String>[command]..addAll(options);
|
||||
return exec(path.join(flutterDirectory.path, 'bin', 'flutter'), args,
|
||||
canFail: canFail, environment: environment);
|
||||
}
|
||||
@ -264,7 +264,7 @@ Future<String> evalFlutter(String command, {
|
||||
bool canFail: false,
|
||||
Map<String, String> environment,
|
||||
}) {
|
||||
List<String> args = <String>[command]..addAll(options);
|
||||
final List<String> args = <String>[command]..addAll(options);
|
||||
return eval(path.join(flutterDirectory.path, 'bin', 'flutter'), args,
|
||||
canFail: canFail, environment: environment);
|
||||
}
|
||||
@ -275,7 +275,7 @@ String get dartBin =>
|
||||
Future<int> dart(List<String> args) => exec(dartBin, args);
|
||||
|
||||
Future<dynamic> inDirectory(dynamic directory, Future<dynamic> action()) async {
|
||||
String previousCwd = cwd;
|
||||
final String previousCwd = cwd;
|
||||
try {
|
||||
cd(directory);
|
||||
return await action();
|
||||
@ -303,7 +303,7 @@ void cd(dynamic directory) {
|
||||
Directory get flutterDirectory => dir('../..').absolute;
|
||||
|
||||
String requireEnvVar(String name) {
|
||||
String value = Platform.environment[name];
|
||||
final String value = Platform.environment[name];
|
||||
|
||||
if (value == null) fail('$name environment variable is missing. Quitting.');
|
||||
|
||||
@ -313,7 +313,7 @@ String requireEnvVar(String name) {
|
||||
T requireConfigProperty<T>(Map<String, dynamic> map, String propertyName) {
|
||||
if (!map.containsKey(propertyName))
|
||||
fail('Configuration property not found: $propertyName');
|
||||
T result = map[propertyName];
|
||||
final T result = map[propertyName];
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -426,7 +426,7 @@ Iterable<String> grep(Pattern pattern, {@required String from}) {
|
||||
///
|
||||
/// }
|
||||
Future<Null> runAndCaptureAsyncStacks(Future<Null> callback()) {
|
||||
Completer<Null> completer = new Completer<Null>();
|
||||
final Completer<Null> completer = new Completer<Null>();
|
||||
Chain.capture(() async {
|
||||
await callback();
|
||||
completer.complete();
|
||||
@ -441,7 +441,7 @@ Future<int> findAvailablePort() async {
|
||||
int port = 20000;
|
||||
while (true) {
|
||||
try {
|
||||
ServerSocket socket =
|
||||
final ServerSocket socket =
|
||||
await ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, port);
|
||||
await socket.close();
|
||||
return port;
|
||||
|
@ -18,10 +18,10 @@ TaskFunction createGalleryTransitionTest() {
|
||||
class GalleryTransitionTest {
|
||||
|
||||
Future<TaskResult> call() async {
|
||||
Device device = await devices.workingDevice;
|
||||
final Device device = await devices.workingDevice;
|
||||
await device.unlock();
|
||||
String deviceId = device.deviceId;
|
||||
Directory galleryDirectory =
|
||||
final String deviceId = device.deviceId;
|
||||
final Directory galleryDirectory =
|
||||
dir('${flutterDirectory.path}/examples/flutter_gallery');
|
||||
await inDirectory(galleryDirectory, () async {
|
||||
await flutter('packages', options: <String>['get']);
|
||||
@ -43,17 +43,17 @@ class GalleryTransitionTest {
|
||||
|
||||
// Route paths contains slashes, which Firebase doesn't accept in keys, so we
|
||||
// remove them.
|
||||
Map<String, List<int>> original = JSON.decode(file(
|
||||
final Map<String, List<int>> original = JSON.decode(file(
|
||||
'${galleryDirectory.path}/build/transition_durations.timeline.json')
|
||||
.readAsStringSync());
|
||||
Map<String, List<int>> transitions = new Map<String, List<int>>.fromIterable(
|
||||
final Map<String, List<int>> transitions = new Map<String, List<int>>.fromIterable(
|
||||
original.keys,
|
||||
key: (String key) => key.replaceAll('/', ''),
|
||||
value: (String key) => original[key]);
|
||||
|
||||
Map<String, dynamic> summary = JSON.decode(file('${galleryDirectory.path}/build/transitions.timeline_summary.json').readAsStringSync());
|
||||
final Map<String, dynamic> summary = JSON.decode(file('${galleryDirectory.path}/build/transitions.timeline_summary.json').readAsStringSync());
|
||||
|
||||
Map<String, dynamic> data = <String, dynamic>{
|
||||
final Map<String, dynamic> data = <String, dynamic>{
|
||||
'transitions': transitions,
|
||||
'missed_transition_count': _countMissedTransitions(transitions),
|
||||
};
|
||||
@ -75,7 +75,7 @@ int _countMissedTransitions(Map<String, List<int>> transitions) {
|
||||
const int _kTransitionBudget = 100000; // µs
|
||||
int count = 0;
|
||||
transitions.forEach((String demoName, List<int> durations) {
|
||||
int longestDuration = durations.reduce(math.max);
|
||||
final int longestDuration = durations.reduce(math.max);
|
||||
if (longestDuration > _kTransitionBudget) {
|
||||
print('$demoName missed transition time budget ($longestDuration µs > $_kTransitionBudget µs)');
|
||||
count++;
|
||||
|
@ -16,13 +16,13 @@ import 'package:flutter_devicelab/framework/utils.dart';
|
||||
/// `dev/benchmarks/microbenchmarks` reports results to the dashboard.
|
||||
TaskFunction createMicrobenchmarkTask() {
|
||||
return () async {
|
||||
Device device = await devices.workingDevice;
|
||||
final Device device = await devices.workingDevice;
|
||||
await device.unlock();
|
||||
|
||||
Future<Map<String, double>> _runMicrobench(String benchmarkPath) async {
|
||||
print('Running $benchmarkPath');
|
||||
Directory appDir = dir(path.join(flutterDirectory.path, 'dev/benchmarks/microbenchmarks'));
|
||||
Process flutterProcess = await inDirectory(appDir, () async {
|
||||
final Directory appDir = dir(path.join(flutterDirectory.path, 'dev/benchmarks/microbenchmarks'));
|
||||
final Process flutterProcess = await inDirectory(appDir, () async {
|
||||
return await _startFlutter(
|
||||
options: <String>[
|
||||
'--profile', // --release doesn't work on iOS due to code signing issues
|
||||
@ -37,7 +37,7 @@ TaskFunction createMicrobenchmarkTask() {
|
||||
return await _readJsonResults(flutterProcess);
|
||||
}
|
||||
|
||||
Map<String, double> allResults = <String, double>{};
|
||||
final Map<String, double> allResults = <String, double>{};
|
||||
allResults.addAll(await _runMicrobench('lib/stocks/layout_bench.dart'));
|
||||
allResults.addAll(await _runMicrobench('lib/stocks/build_bench.dart'));
|
||||
allResults.addAll(await _runMicrobench('lib/gestures/velocity_tracker_bench.dart'));
|
||||
@ -53,7 +53,7 @@ Future<Process> _startFlutter({
|
||||
bool canFail: false,
|
||||
Map<String, String> environment,
|
||||
}) {
|
||||
List<String> args = <String>['run']..addAll(options);
|
||||
final List<String> args = <String>['run']..addAll(options);
|
||||
return startProcess(path.join(flutterDirectory.path, 'bin', 'flutter'), args, environment: environment);
|
||||
}
|
||||
|
||||
@ -62,8 +62,8 @@ Future<Map<String, double>> _readJsonResults(Process process) {
|
||||
const String jsonStart = '================ RESULTS ================';
|
||||
const String jsonEnd = '================ FORMATTED ==============';
|
||||
bool jsonStarted = false;
|
||||
StringBuffer jsonBuf = new StringBuffer();
|
||||
Completer<Map<String, double>> completer = new Completer<Map<String, double>>();
|
||||
final StringBuffer jsonBuf = new StringBuffer();
|
||||
final Completer<Map<String, double>> completer = new Completer<Map<String, double>>();
|
||||
StreamSubscription<String> stdoutSub;
|
||||
|
||||
int prefixLength = 0;
|
||||
|
@ -77,7 +77,7 @@ class StartupTest {
|
||||
|
||||
Future<TaskResult> call() async {
|
||||
return await inDirectory(testDirectory, () async {
|
||||
String deviceId = (await devices.workingDevice).deviceId;
|
||||
final String deviceId = (await devices.workingDevice).deviceId;
|
||||
await flutter('packages', options: <String>['get']);
|
||||
|
||||
if (deviceOperatingSystem == DeviceOperatingSystem.ios) {
|
||||
@ -91,7 +91,7 @@ class StartupTest {
|
||||
'-d',
|
||||
deviceId,
|
||||
]).timeout(_startupTimeout);
|
||||
Map<String, dynamic> data = JSON.decode(file('$testDirectory/build/start_up_info.json').readAsStringSync());
|
||||
final Map<String, dynamic> data = JSON.decode(file('$testDirectory/build/start_up_info.json').readAsStringSync());
|
||||
return new TaskResult.success(data, benchmarkScoreKeys: <String>[
|
||||
'timeToFirstFrameMicros',
|
||||
]);
|
||||
@ -111,9 +111,9 @@ class PerfTest {
|
||||
|
||||
Future<TaskResult> call() {
|
||||
return inDirectory(testDirectory, () async {
|
||||
Device device = await devices.workingDevice;
|
||||
final Device device = await devices.workingDevice;
|
||||
await device.unlock();
|
||||
String deviceId = device.deviceId;
|
||||
final String deviceId = device.deviceId;
|
||||
await flutter('packages', options: <String>['get']);
|
||||
|
||||
if (deviceOperatingSystem == DeviceOperatingSystem.ios) {
|
||||
@ -130,7 +130,7 @@ class PerfTest {
|
||||
'-d',
|
||||
deviceId,
|
||||
]);
|
||||
Map<String, dynamic> data = JSON.decode(file('$testDirectory/build/$timelineFileName.timeline_summary.json').readAsStringSync());
|
||||
final Map<String, dynamic> data = JSON.decode(file('$testDirectory/build/$timelineFileName.timeline_summary.json').readAsStringSync());
|
||||
|
||||
if (data['frame_count'] < 5) {
|
||||
return new TaskResult.failure(
|
||||
@ -159,12 +159,12 @@ class BuildTest {
|
||||
|
||||
Future<TaskResult> call() async {
|
||||
return await inDirectory(testDirectory, () async {
|
||||
Device device = await devices.workingDevice;
|
||||
final Device device = await devices.workingDevice;
|
||||
await device.unlock();
|
||||
await flutter('packages', options: <String>['get']);
|
||||
|
||||
Stopwatch watch = new Stopwatch()..start();
|
||||
String buildLog = await evalFlutter('build', options: <String>[
|
||||
final Stopwatch watch = new Stopwatch()..start();
|
||||
final String buildLog = await evalFlutter('build', options: <String>[
|
||||
'aot',
|
||||
'-v',
|
||||
'--profile',
|
||||
@ -173,9 +173,9 @@ class BuildTest {
|
||||
]);
|
||||
watch.stop();
|
||||
|
||||
RegExp metricExpression = new RegExp(r'([a-zA-Z]+)\(CodeSize\)\: (\d+)');
|
||||
final RegExp metricExpression = new RegExp(r'([a-zA-Z]+)\(CodeSize\)\: (\d+)');
|
||||
|
||||
Map<String, dynamic> data = new Map<String, dynamic>.fromIterable(
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>.fromIterable(
|
||||
metricExpression.allMatches(buildLog),
|
||||
key: (Match m) => _sdkNameToMetricName(m.group(1)),
|
||||
value: (Match m) => int.parse(m.group(2)),
|
||||
@ -216,9 +216,9 @@ class MemoryTest {
|
||||
|
||||
Future<TaskResult> call() {
|
||||
return inDirectory(testDirectory, () async {
|
||||
Device device = await devices.workingDevice;
|
||||
final Device device = await devices.workingDevice;
|
||||
await device.unlock();
|
||||
String deviceId = device.deviceId;
|
||||
final String deviceId = device.deviceId;
|
||||
await flutter('packages', options: <String>['get']);
|
||||
|
||||
if (deviceOperatingSystem == DeviceOperatingSystem.ios) {
|
||||
@ -226,9 +226,9 @@ class MemoryTest {
|
||||
await flutter('build', options: <String>['ios', '--profile']);
|
||||
}
|
||||
|
||||
int observatoryPort = await findAvailablePort();
|
||||
final int observatoryPort = await findAvailablePort();
|
||||
|
||||
List<String> runOptions = <String>[
|
||||
final List<String> runOptions = <String>[
|
||||
'-v',
|
||||
'--profile',
|
||||
'--trace-startup', // wait for the first frame to render
|
||||
@ -241,9 +241,9 @@ class MemoryTest {
|
||||
runOptions.addAll(<String>['-t', testTarget]);
|
||||
await flutter('run', options: runOptions);
|
||||
|
||||
Map<String, dynamic> startData = await device.getMemoryStats(packageName);
|
||||
final Map<String, dynamic> startData = await device.getMemoryStats(packageName);
|
||||
|
||||
Map<String, dynamic> data = <String, dynamic>{
|
||||
final Map<String, dynamic> data = <String, dynamic>{
|
||||
'start_total_kb': startData['total_kb'],
|
||||
};
|
||||
|
||||
@ -257,7 +257,7 @@ class MemoryTest {
|
||||
'--use-existing-app=http://localhost:$observatoryPort',
|
||||
]);
|
||||
|
||||
Map<String, dynamic> endData = await device.getMemoryStats(packageName);
|
||||
final Map<String, dynamic> endData = await device.getMemoryStats(packageName);
|
||||
data['end_total_kb'] = endData['total_kb'];
|
||||
data['diff_total_kb'] = endData['total_kb'] - startData['total_kb'];
|
||||
}
|
||||
@ -283,9 +283,9 @@ class AndroidBackButtonMemoryTest {
|
||||
throw 'This test is only supported on Android';
|
||||
}
|
||||
|
||||
AndroidDevice device = await devices.workingDevice;
|
||||
final AndroidDevice device = await devices.workingDevice;
|
||||
await device.unlock();
|
||||
String deviceId = device.deviceId;
|
||||
final String deviceId = device.deviceId;
|
||||
await flutter('packages', options: <String>['get']);
|
||||
|
||||
await flutter('run', options: <String>[
|
||||
@ -296,9 +296,9 @@ class AndroidBackButtonMemoryTest {
|
||||
deviceId,
|
||||
]);
|
||||
|
||||
Map<String, dynamic> startData = await device.getMemoryStats(packageName);
|
||||
final Map<String, dynamic> startData = await device.getMemoryStats(packageName);
|
||||
|
||||
Map<String, dynamic> data = <String, dynamic>{
|
||||
final Map<String, dynamic> data = <String, dynamic>{
|
||||
'start_total_kb': startData['total_kb'],
|
||||
};
|
||||
|
||||
@ -306,14 +306,14 @@ class AndroidBackButtonMemoryTest {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
await device.shellExec('input', <String>['keyevent', 'KEYCODE_BACK']);
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 1000));
|
||||
String output = await device.shellEval('am', <String>['start', '-n', 'io.flutter.examples.gallery/io.flutter.app.FlutterActivity']);
|
||||
final String output = await device.shellEval('am', <String>['start', '-n', 'io.flutter.examples.gallery/io.flutter.app.FlutterActivity']);
|
||||
print(output);
|
||||
if (output.contains('Error'))
|
||||
return new TaskResult.failure('unable to launch activity');
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 1000));
|
||||
}
|
||||
|
||||
Map<String, dynamic> endData = await device.getMemoryStats(packageName);
|
||||
final Map<String, dynamic> endData = await device.getMemoryStats(packageName);
|
||||
data['end_total_kb'] = endData['total_kb'];
|
||||
data['diff_total_kb'] = endData['total_kb'] - startData['total_kb'];
|
||||
|
||||
|
@ -12,7 +12,7 @@ import '../framework/utils.dart';
|
||||
TaskFunction createBasicMaterialAppSizeTest() {
|
||||
return () async {
|
||||
const String sampleAppName = 'sample_flutter_app';
|
||||
Directory sampleDir = dir('${Directory.systemTemp.path}/$sampleAppName');
|
||||
final Directory sampleDir = dir('${Directory.systemTemp.path}/$sampleAppName');
|
||||
|
||||
if (await sampleDir.exists())
|
||||
rmTree(sampleDir);
|
||||
|
@ -129,7 +129,7 @@ class CommandArgs {
|
||||
if (other.runtimeType != CommandArgs)
|
||||
return false;
|
||||
|
||||
CommandArgs otherCmd = other;
|
||||
final CommandArgs otherCmd = other;
|
||||
return otherCmd.command == this.command &&
|
||||
const ListEquality<String>().equals(otherCmd.arguments, this.arguments) &&
|
||||
const MapEquality<String, String>().equals(otherCmd.environment, this.environment);
|
||||
@ -188,7 +188,7 @@ class FakeDevice extends AndroidDevice {
|
||||
arguments: arguments,
|
||||
environment: environment,
|
||||
));
|
||||
dynamic exitError = exitErrorFactory();
|
||||
final dynamic exitError = exitErrorFactory();
|
||||
if (exitError != null)
|
||||
throw exitError;
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ import 'package:flutter_devicelab/framework/manifest.dart';
|
||||
void main() {
|
||||
group('production manifest', () {
|
||||
test('must be valid', () {
|
||||
Manifest manifest = loadTaskManifest();
|
||||
final Manifest manifest = loadTaskManifest();
|
||||
expect(manifest.tasks, isNotEmpty);
|
||||
|
||||
ManifestTask task = manifest.tasks.firstWhere((ManifestTask task) => task.name == 'flutter_gallery__start_up');
|
||||
final ManifestTask task = manifest.tasks.firstWhere((ManifestTask task) => task.name == 'flutter_gallery__start_up');
|
||||
expect(task.description, 'Measures the startup time of the Flutter Gallery app on Android.\n');
|
||||
expect(task.stage, 'devicelab');
|
||||
expect(task.requiredAgentCapabilities, <String>['has-android-device']);
|
||||
|
@ -10,11 +10,11 @@ import 'package:test/test.dart';
|
||||
void main() {
|
||||
group('run.dart script', () {
|
||||
Future<int> runScript(List<String> testNames) async {
|
||||
List<String> options = <String>['bin/run.dart'];
|
||||
final List<String> options = <String>['bin/run.dart'];
|
||||
for (String testName in testNames) {
|
||||
options..addAll(<String>['-t', testName]);
|
||||
}
|
||||
ProcessResult scriptProcess = Process.runSync(
|
||||
final ProcessResult scriptProcess = Process.runSync(
|
||||
'../../bin/cache/dart-sdk/bin/dart',
|
||||
options,
|
||||
);
|
||||
|
@ -42,7 +42,7 @@ class CardCollectionState extends State<CardCollection> {
|
||||
bool _varyFontSizes = false;
|
||||
|
||||
void _initVariableSizedCardModels() {
|
||||
List<double> cardHeights = <double>[
|
||||
final List<double> cardHeights = <double>[
|
||||
48.0, 63.0, 82.0, 146.0, 60.0, 55.0, 84.0, 96.0, 50.0,
|
||||
48.0, 63.0, 82.0, 146.0, 60.0, 55.0, 84.0, 96.0, 50.0,
|
||||
48.0, 63.0, 82.0, 146.0, 60.0, 55.0, 84.0, 96.0, 50.0,
|
||||
@ -119,7 +119,7 @@ class CardCollectionState extends State<CardCollection> {
|
||||
}
|
||||
|
||||
String _dismissDirectionText(DismissDirection direction) {
|
||||
String s = direction.toString();
|
||||
final String s = direction.toString();
|
||||
return "dismiss ${s.substring(s.indexOf('.') + 1)}";
|
||||
}
|
||||
|
||||
@ -247,8 +247,8 @@ class CardCollectionState extends State<CardCollection> {
|
||||
}
|
||||
|
||||
Widget _buildCard(BuildContext context, int index) {
|
||||
CardModel cardModel = _cardModels[index];
|
||||
Widget card = new Dismissable(
|
||||
final CardModel cardModel = _cardModels[index];
|
||||
final Widget card = new Dismissable(
|
||||
key: new ObjectKey(cardModel),
|
||||
direction: _dismissDirection,
|
||||
onDismissed: (DismissDirection direction) { dismissCard(cardModel); },
|
||||
@ -318,7 +318,7 @@ class CardCollectionState extends State<CardCollection> {
|
||||
// size of the background,card Stack will be based only on the card. The
|
||||
// Viewport ensures that when the card's resize animation occurs, the
|
||||
// background (text and icons) will just be clipped, not resized.
|
||||
Widget background = new Positioned.fill(
|
||||
final Widget background = new Positioned.fill(
|
||||
child: new Container(
|
||||
margin: const EdgeInsets.all(4.0),
|
||||
child: new SingleChildScrollView(
|
||||
@ -376,7 +376,7 @@ class CardCollectionState extends State<CardCollection> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget body = new Container(
|
||||
final Widget body = new Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 8.0),
|
||||
color: _primaryColor[50],
|
||||
child: cardCollection,
|
||||
|
@ -97,7 +97,7 @@ class ExampleDragSource extends StatelessWidget {
|
||||
if (heavy)
|
||||
size *= kHeavyMultiplier;
|
||||
|
||||
Widget contents = new DefaultTextStyle(
|
||||
final Widget contents = new DefaultTextStyle(
|
||||
style: Theme.of(context).textTheme.body1,
|
||||
textAlign: TextAlign.center,
|
||||
child: new Dot(
|
||||
@ -185,7 +185,7 @@ class MovableBall extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget ball = new DefaultTextStyle(
|
||||
final Widget ball = new DefaultTextStyle(
|
||||
style: Theme.of(context).primaryTextTheme.body1,
|
||||
textAlign: TextAlign.center,
|
||||
child: new Dot(
|
||||
@ -196,7 +196,7 @@ class MovableBall extends StatelessWidget {
|
||||
child: new Center(child: new Text('BALL'))
|
||||
)
|
||||
);
|
||||
Widget dashedBall = new Container(
|
||||
final Widget dashedBall = new Container(
|
||||
width: kBallSize,
|
||||
height: kBallSize,
|
||||
child: new CustomPaint(
|
||||
|
@ -31,8 +31,8 @@ class _MarkerPainter extends CustomPainter {
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, _) {
|
||||
Paint paint = new Paint()..color = const Color(0x8000FF00);
|
||||
double r = size / 2.0;
|
||||
final Paint paint = new Paint()..color = const Color(0x8000FF00);
|
||||
final double r = size / 2.0;
|
||||
canvas.drawCircle(new Point(r, r), r, paint);
|
||||
|
||||
paint
|
||||
@ -107,7 +107,7 @@ class CardBuilder extends SliverChildDelegate {
|
||||
Widget build(BuildContext context, int index) {
|
||||
if (index >= cardModels.length)
|
||||
return null;
|
||||
CardModel cardModel = cardModels[index];
|
||||
final CardModel cardModel = cardModels[index];
|
||||
return new GestureDetector(
|
||||
key: cardModel.key,
|
||||
onTapUp: (TapUpDetails details) { onTapUp(cardModel.targetKey, details.globalPosition); },
|
||||
@ -140,13 +140,13 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
List<double> cardHeights = <double>[
|
||||
final List<double> cardHeights = <double>[
|
||||
48.0, 63.0, 82.0, 146.0, 60.0, 55.0, 84.0, 96.0, 50.0,
|
||||
48.0, 63.0, 82.0, 146.0, 60.0, 55.0, 84.0, 96.0, 50.0,
|
||||
48.0, 63.0, 82.0, 146.0, 60.0, 55.0, 84.0, 96.0, 50.0,
|
||||
];
|
||||
cardModels = new List<CardModel>.generate(cardHeights.length, (int i) {
|
||||
Color color = Color.lerp(Colors.red[300], Colors.blue[900], i / cardHeights.length);
|
||||
final Color color = Color.lerp(Colors.red[300], Colors.blue[900], i / cardHeights.length);
|
||||
return new CardModel(i, cardHeights[i], color);
|
||||
});
|
||||
}
|
||||
@ -154,10 +154,10 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
|
||||
bool handleScrollNotification(ScrollNotification notification) {
|
||||
if (notification is ScrollUpdateNotification && notification.depth == 1) {
|
||||
setState(() {
|
||||
double dy = markersScrollOffset - notification.metrics.extentBefore;
|
||||
final double dy = markersScrollOffset - notification.metrics.extentBefore;
|
||||
markersScrollOffset = notification.metrics.extentBefore;
|
||||
for (MarkerType type in markers.keys) {
|
||||
Point oldPosition = markers[type];
|
||||
final Point oldPosition = markers[type];
|
||||
markers[type] = new Point(oldPosition.x, oldPosition.y + dy);
|
||||
}
|
||||
});
|
||||
@ -179,7 +179,7 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> layers = <Widget>[
|
||||
final List<Widget> layers = <Widget>[
|
||||
new Scaffold(
|
||||
appBar: new AppBar(title: new Text('Tap a Card')),
|
||||
body: new Container(
|
||||
|
@ -31,7 +31,7 @@ class PageViewAppState extends State<PageViewApp> {
|
||||
];
|
||||
|
||||
cardModels = new List<CardModel>.generate(cardSizes.length, (int i) {
|
||||
Color color = Color.lerp(Colors.red[300], Colors.blue[900], i / cardSizes.length);
|
||||
final Color color = Color.lerp(Colors.red[300], Colors.blue[900], i / cardSizes.length);
|
||||
return new CardModel(i, cardSizes[i], color);
|
||||
});
|
||||
}
|
||||
@ -45,7 +45,7 @@ class PageViewAppState extends State<PageViewApp> {
|
||||
bool itemsWrap = false;
|
||||
|
||||
Widget buildCard(CardModel cardModel) {
|
||||
Widget card = new Card(
|
||||
final Widget card = new Card(
|
||||
color: cardModel.color,
|
||||
child: new Container(
|
||||
width: cardModel.size.width,
|
||||
@ -55,7 +55,7 @@ class PageViewAppState extends State<PageViewApp> {
|
||||
),
|
||||
);
|
||||
|
||||
BoxConstraints constraints = (scrollDirection == Axis.vertical)
|
||||
final BoxConstraints constraints = (scrollDirection == Axis.vertical)
|
||||
? new BoxConstraints.tightFor(height: pageSize.height)
|
||||
: new BoxConstraints.tightFor(width: pageSize.width);
|
||||
|
||||
|
@ -13,7 +13,7 @@ void main() {
|
||||
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
|
||||
await tester.pump(); // triggers a frame
|
||||
|
||||
Finder navigationMenu = find.byWidgetPredicate((Widget widget) {
|
||||
final Finder navigationMenu = find.byWidgetPredicate((Widget widget) {
|
||||
if (widget is Tooltip)
|
||||
return widget.message == 'Open navigation menu';
|
||||
return false;
|
||||
|
@ -25,7 +25,7 @@ Future<Null> main(List<String> args) async {
|
||||
Directory.current = Directory.current.parent.parent;
|
||||
|
||||
// Create the pubspec.yaml file.
|
||||
StringBuffer buf = new StringBuffer('''
|
||||
final StringBuffer buf = new StringBuffer('''
|
||||
name: Flutter
|
||||
dependencies:
|
||||
''');
|
||||
@ -40,10 +40,10 @@ dependencies:
|
||||
new File('dev/docs/pubspec.yaml').writeAsStringSync(buf.toString());
|
||||
|
||||
// Create the library file.
|
||||
Directory libDir = new Directory('dev/docs/lib');
|
||||
final Directory libDir = new Directory('dev/docs/lib');
|
||||
libDir.createSync();
|
||||
|
||||
StringBuffer contents = new StringBuffer('library temp_doc;\n\n');
|
||||
final StringBuffer contents = new StringBuffer('library temp_doc;\n\n');
|
||||
for (String libraryRef in libraryRefs()) {
|
||||
contents.writeln('import \'package:$libraryRef\';');
|
||||
}
|
||||
@ -58,14 +58,14 @@ dependencies:
|
||||
);
|
||||
printStream(process.stdout);
|
||||
printStream(process.stderr);
|
||||
int code = await process.exitCode;
|
||||
final int code = await process.exitCode;
|
||||
if (code != 0)
|
||||
exit(code);
|
||||
|
||||
createFooter('dev/docs/lib/footer.html');
|
||||
|
||||
// Generate the documentation.
|
||||
List<String> args = <String>[
|
||||
final List<String> args = <String>[
|
||||
'global', 'run', 'dartdoc',
|
||||
'--header', 'styles.html',
|
||||
'--header', 'analytics.html',
|
||||
@ -84,7 +84,7 @@ dependencies:
|
||||
process = await Process.start('pub', args, workingDirectory: 'dev/docs');
|
||||
printStream(process.stdout);
|
||||
printStream(process.stderr);
|
||||
int exitCode = await process.exitCode;
|
||||
final int exitCode = await process.exitCode;
|
||||
|
||||
if (exitCode != 0)
|
||||
exit(exitCode);
|
||||
@ -95,10 +95,10 @@ dependencies:
|
||||
}
|
||||
|
||||
void createFooter(String footerPath) {
|
||||
ProcessResult gitResult = Process.runSync('git', <String>['rev-parse', 'HEAD']);
|
||||
String gitHead = (gitResult.exitCode == 0) ? gitResult.stdout.trim() : 'unknown';
|
||||
final ProcessResult gitResult = Process.runSync('git', <String>['rev-parse', 'HEAD']);
|
||||
final String gitHead = (gitResult.exitCode == 0) ? gitResult.stdout.trim() : 'unknown';
|
||||
|
||||
String timestamp = new DateFormat('yyyy-MM-dd HH:mm').format(new DateTime.now());
|
||||
final String timestamp = new DateFormat('yyyy-MM-dd HH:mm').format(new DateTime.now());
|
||||
|
||||
new File(footerPath).writeAsStringSync(
|
||||
'<p class="text-center" style="font-size: 10px">'
|
||||
@ -107,7 +107,7 @@ void createFooter(String footerPath) {
|
||||
}
|
||||
|
||||
void sanityCheckDocs() {
|
||||
List<String> canaries = <String>[
|
||||
final List<String> canaries = <String>[
|
||||
'$kDocRoot/api/dart-io/File-class.html',
|
||||
'$kDocRoot/api/dart-ui/Canvas-class.html',
|
||||
'$kDocRoot/api/dart-ui/Canvas/drawRect.html',
|
||||
@ -151,7 +151,7 @@ void copyIndexToRootOfDocs() {
|
||||
}
|
||||
|
||||
void addHtmlBaseToIndex() {
|
||||
File indexFile = new File('$kDocRoot/index.html');
|
||||
final File indexFile = new File('$kDocRoot/index.html');
|
||||
String indexContents = indexFile.readAsStringSync();
|
||||
indexContents = indexContents.replaceFirst('</title>\n',
|
||||
'</title>\n <base href="./flutter/">\n');
|
||||
@ -163,7 +163,7 @@ void addHtmlBaseToIndex() {
|
||||
}
|
||||
|
||||
void putRedirectInOldIndexLocation() {
|
||||
String metaTag = '<meta http-equiv="refresh" content="0;URL=../index.html">';
|
||||
final String metaTag = '<meta http-equiv="refresh" content="0;URL=../index.html">';
|
||||
new File('$kDocRoot/flutter/index.html').writeAsStringSync(metaTag);
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ List<Directory> findPackages() {
|
||||
.where((FileSystemEntity entity) {
|
||||
if (entity is! Directory)
|
||||
return false;
|
||||
File pubspec = new File('${entity.path}/pubspec.yaml');
|
||||
final File pubspec = new File('${entity.path}/pubspec.yaml');
|
||||
// TODO(ianh): Use a real YAML parser here
|
||||
return !pubspec.readAsStringSync().contains('nodoc: true');
|
||||
})
|
||||
@ -190,7 +190,7 @@ List<Directory> findPackages() {
|
||||
/// diskPath toggles between import paths vs. disk paths.
|
||||
Iterable<String> libraryRefs({ bool diskPath: false }) sync* {
|
||||
for (Directory dir in findPackages()) {
|
||||
String dirName = path.basename(dir.path);
|
||||
final String dirName = path.basename(dir.path);
|
||||
for (FileSystemEntity file in new Directory('${dir.path}/lib').listSync()) {
|
||||
if (file is File && file.path.endsWith('.dart')) {
|
||||
if (diskPath)
|
||||
|
@ -13,26 +13,26 @@ const String kDocRoot = 'dev/docs/doc';
|
||||
/// This script downloads an archive of Javadoc for the engine from the
|
||||
/// artifact store and extracts it to the location used for Dartdoc.
|
||||
Future<Null> main(List<String> args) async {
|
||||
String engineVersion = new File('bin/internal/engine.version').readAsStringSync().trim();
|
||||
final String engineVersion = new File('bin/internal/engine.version').readAsStringSync().trim();
|
||||
|
||||
String url = 'https://storage.googleapis.com/flutter_infra/flutter/$engineVersion/android-javadoc.zip';
|
||||
http.Response response = await http.get(url);
|
||||
final String url = 'https://storage.googleapis.com/flutter_infra/flutter/$engineVersion/android-javadoc.zip';
|
||||
final http.Response response = await http.get(url);
|
||||
|
||||
Archive archive = new ZipDecoder().decodeBytes(response.bodyBytes);
|
||||
final Archive archive = new ZipDecoder().decodeBytes(response.bodyBytes);
|
||||
|
||||
Directory output = new Directory('$kDocRoot/javadoc');
|
||||
final Directory output = new Directory('$kDocRoot/javadoc');
|
||||
print('Extracing javadoc to ${output.path}');
|
||||
output.createSync(recursive: true);
|
||||
|
||||
for (ArchiveFile af in archive) {
|
||||
if (af.isFile) {
|
||||
File file = new File('${output.path}/${af.name}');
|
||||
final File file = new File('${output.path}/${af.name}');
|
||||
file.createSync(recursive: true);
|
||||
file.writeAsBytesSync(af.content);
|
||||
}
|
||||
}
|
||||
|
||||
File testFile = new File('${output.path}/io/flutter/view/FlutterView.html');
|
||||
final File testFile = new File('${output.path}/io/flutter/view/FlutterView.html');
|
||||
if (!testFile.existsSync()) {
|
||||
print('Expected file ${testFile.path} not found');
|
||||
exit(1);
|
||||
|
@ -17,14 +17,14 @@ void main(List<String> args) {
|
||||
if (path.basename(Directory.current.path) == 'tools')
|
||||
Directory.current = Directory.current.parent.parent;
|
||||
|
||||
ArgParser argParser = new ArgParser();
|
||||
final ArgParser argParser = new ArgParser();
|
||||
// ../mega_gallery? dev/benchmarks/mega_gallery?
|
||||
argParser.addOption('out', defaultsTo: _normalize('dev/benchmarks/mega_gallery'));
|
||||
argParser.addOption('copies');
|
||||
argParser.addFlag('delete', negatable: false);
|
||||
argParser.addFlag('help', abbr: 'h', negatable: false);
|
||||
|
||||
ArgResults results = argParser.parse(args);
|
||||
final ArgResults results = argParser.parse(args);
|
||||
|
||||
if (results['help']) {
|
||||
print('Generate n copies of flutter_gallery.\n');
|
||||
@ -33,8 +33,8 @@ void main(List<String> args) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
Directory source = new Directory(_normalize('examples/flutter_gallery'));
|
||||
Directory out = new Directory(_normalize(results['out']));
|
||||
final Directory source = new Directory(_normalize('examples/flutter_gallery'));
|
||||
final Directory out = new Directory(_normalize(results['out']));
|
||||
|
||||
if (results['delete']) {
|
||||
if (out.existsSync()) {
|
||||
@ -47,7 +47,7 @@ void main(List<String> args) {
|
||||
|
||||
int copies;
|
||||
if (!results.wasParsed('copies')) {
|
||||
SourceStats stats = getStatsFor(_dir(source, 'lib'));
|
||||
final SourceStats stats = getStatsFor(_dir(source, 'lib'));
|
||||
copies = (kTargetLineCount / stats.lines).round();
|
||||
} else {
|
||||
copies = int.parse(results['copies']);
|
||||
@ -59,7 +59,7 @@ void main(List<String> args) {
|
||||
print(' packages/flutter : ${getStatsFor(new Directory("packages/flutter"))}');
|
||||
print(' examples/flutter_gallery : ${getStatsFor(new Directory("examples/flutter_gallery"))}');
|
||||
|
||||
Directory lib = _dir(out, 'lib');
|
||||
final Directory lib = _dir(out, 'lib');
|
||||
if (lib.existsSync())
|
||||
lib.deleteSync(recursive: true);
|
||||
|
||||
@ -86,15 +86,15 @@ void main(List<String> args) {
|
||||
|
||||
// TODO(devoncarew): Create an entry-point that builds a UI with all `n` copies.
|
||||
void _createEntry(File mainFile, int copies) {
|
||||
StringBuffer imports = new StringBuffer();
|
||||
StringBuffer importRefs = new StringBuffer();
|
||||
final StringBuffer imports = new StringBuffer();
|
||||
final StringBuffer importRefs = new StringBuffer();
|
||||
|
||||
for (int i = 1; i < copies; i++) {
|
||||
imports.writeln("import 'gallery_$i/main.dart' as main_$i;");
|
||||
importRefs.writeln(" main_$i.main;");
|
||||
}
|
||||
|
||||
String contents = '''
|
||||
final String contents = '''
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
@ -116,8 +116,8 @@ void main() {
|
||||
}
|
||||
|
||||
void _copyGallery(Directory galleryDir, int index) {
|
||||
Directory lib = _dir(galleryDir, 'lib');
|
||||
Directory dest = _dir(lib, 'gallery_$index');
|
||||
final Directory lib = _dir(galleryDir, 'lib');
|
||||
final Directory dest = _dir(lib, 'gallery_$index');
|
||||
dest.createSync();
|
||||
|
||||
// Copy demo/, gallery/, and main.dart.
|
||||
@ -131,7 +131,7 @@ void _copy(Directory source, Directory target) {
|
||||
target.createSync();
|
||||
|
||||
for (FileSystemEntity entity in source.listSync(followLinks: false)) {
|
||||
String name = path.basename(entity.path);
|
||||
final String name = path.basename(entity.path);
|
||||
|
||||
if (entity is Directory) {
|
||||
if (name == 'build' || name.startsWith('.'))
|
||||
@ -140,7 +140,7 @@ void _copy(Directory source, Directory target) {
|
||||
} else if (entity is File) {
|
||||
if (name == '.packages' || name == 'pubspec.lock')
|
||||
continue;
|
||||
File dest = new File(path.join(target.path, name));
|
||||
final File dest = new File(path.join(target.path, name));
|
||||
dest.writeAsBytesSync(entity.readAsBytesSync());
|
||||
}
|
||||
}
|
||||
@ -162,7 +162,7 @@ SourceStats getStatsFor(Directory dir, [SourceStats stats]) {
|
||||
stats ??= new SourceStats();
|
||||
|
||||
for (FileSystemEntity entity in dir.listSync(recursive: false, followLinks: false)) {
|
||||
String name = path.basename(entity.path);
|
||||
final String name = path.basename(entity.path);
|
||||
if (entity is File && name.endsWith('.dart')) {
|
||||
stats.files += 1;
|
||||
stats.lines += _lineCount(entity);
|
||||
@ -184,7 +184,7 @@ int _lineCount(File file) {
|
||||
}
|
||||
|
||||
String _comma(int count) {
|
||||
String str = count.toString();
|
||||
final String str = count.toString();
|
||||
if (str.length > 3)
|
||||
return str.substring(0, str.length - 3) + ',' + str.substring(str.length - 3);
|
||||
return str;
|
||||
|
@ -33,26 +33,26 @@ void main(List<String> args) {
|
||||
if (path.basename(Directory.current.path) == 'tools')
|
||||
Directory.current = Directory.current.parent.parent;
|
||||
|
||||
ArgParser argParser = new ArgParser();
|
||||
final ArgParser argParser = new ArgParser();
|
||||
argParser.addOption(kOptionCodepointsPath, defaultsTo: kDefaultCodepointsPath);
|
||||
argParser.addOption(kOptionIconsPath, defaultsTo: kDefaultIconsPath);
|
||||
argParser.addFlag(kOptionDryRun, defaultsTo: false);
|
||||
ArgResults argResults = argParser.parse(args);
|
||||
final ArgResults argResults = argParser.parse(args);
|
||||
|
||||
File iconFile = new File(path.absolute(argResults[kOptionIconsPath]));
|
||||
final File iconFile = new File(path.absolute(argResults[kOptionIconsPath]));
|
||||
if (!iconFile.existsSync()) {
|
||||
stderr.writeln('Icons file not found: ${iconFile.path}');
|
||||
exit(1);
|
||||
}
|
||||
File codepointsFile = new File(path.absolute(argResults[kOptionCodepointsPath]));
|
||||
final File codepointsFile = new File(path.absolute(argResults[kOptionCodepointsPath]));
|
||||
if (!codepointsFile.existsSync()) {
|
||||
stderr.writeln('Codepoints file not found: ${codepointsFile.path}');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
String iconData = iconFile.readAsStringSync();
|
||||
String codepointData = codepointsFile.readAsStringSync();
|
||||
String newIconData = regenerateIconsFile(iconData, codepointData);
|
||||
final String iconData = iconFile.readAsStringSync();
|
||||
final String codepointData = codepointsFile.readAsStringSync();
|
||||
final String newIconData = regenerateIconsFile(iconData, codepointData);
|
||||
|
||||
if (argResults[kOptionDryRun])
|
||||
stdout.writeln(newIconData);
|
||||
@ -61,14 +61,14 @@ void main(List<String> args) {
|
||||
}
|
||||
|
||||
String regenerateIconsFile(String iconData, String codepointData) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
final StringBuffer buf = new StringBuffer();
|
||||
bool generating = false;
|
||||
for (String line in LineSplitter.split(iconData)) {
|
||||
if (!generating)
|
||||
buf.writeln(line);
|
||||
if (line.contains(kBeginGeneratedMark)) {
|
||||
generating = true;
|
||||
String iconDeclarations = generateIconDeclarations(codepointData);
|
||||
final String iconDeclarations = generateIconDeclarations(codepointData);
|
||||
buf.write(iconDeclarations);
|
||||
} else if (line.contains(kEndGeneratedMark)) {
|
||||
generating = false;
|
||||
@ -87,13 +87,13 @@ String generateIconDeclarations(String codepointData) {
|
||||
}
|
||||
|
||||
String getIconDeclaration(String line) {
|
||||
List<String> tokens = line.split(' ');
|
||||
final List<String> tokens = line.split(' ');
|
||||
if (tokens.length != 2)
|
||||
throw new FormatException('Unexpected codepoint data: $line');
|
||||
String name = tokens[0];
|
||||
String codepoint = tokens[1];
|
||||
String identifier = kIdentifierRewrites[name] ?? name;
|
||||
String description = name.replaceAll('_', ' ');
|
||||
final String name = tokens[0];
|
||||
final String codepoint = tokens[1];
|
||||
final String identifier = kIdentifierRewrites[name] ?? name;
|
||||
final String description = name.replaceAll('_', ' ');
|
||||
return '''
|
||||
|
||||
/// <p><i class="material-icons md-36">$name</i> — material icon named "$description".</p>
|
||||
|
Loading…
Reference in New Issue
Block a user