enable lints prefer_spread_collections and prefer_inlined_adds (#35189)
This commit is contained in:
committed by
GitHub
parent
31cf49a9c9
commit
919dcf53f3
@@ -117,11 +117,12 @@ class AnimatedBezierState extends State<AnimatedBezier>
|
||||
AnimationController controller;
|
||||
CurvedAnimation curve;
|
||||
bool isPlaying = false;
|
||||
List<List<Point>> pointList = <List<Point>>[]
|
||||
..add(<Point>[])
|
||||
..add(<Point>[])
|
||||
..add(<Point>[])
|
||||
..add(<Point>[]);
|
||||
List<List<Point>> pointList = <List<Point>>[
|
||||
<Point>[],
|
||||
<Point>[],
|
||||
<Point>[],
|
||||
<Point>[],
|
||||
];
|
||||
bool isReversed = false;
|
||||
|
||||
List<PathDetail> _playForward() {
|
||||
|
||||
@@ -286,13 +286,14 @@ class SampleChecker {
|
||||
'--snapshot=$_snippetsSnapshotPath',
|
||||
'--snapshot-kind=app-jit',
|
||||
path.canonicalize(_snippetsExecutable),
|
||||
]..addAll(args),
|
||||
...args,
|
||||
],
|
||||
workingDirectory: workingDirectory,
|
||||
);
|
||||
} else {
|
||||
return Process.runSync(
|
||||
_dartExecutable,
|
||||
<String>[path.canonicalize(_snippetsSnapshotPath)]..addAll(args),
|
||||
<String>[path.canonicalize(_snippetsSnapshotPath), ...args],
|
||||
workingDirectory: workingDirectory,
|
||||
);
|
||||
}
|
||||
@@ -311,7 +312,8 @@ class SampleChecker {
|
||||
final List<String> args = <String>[
|
||||
'--output=${outputFile.absolute.path}',
|
||||
'--input=${inputFile.absolute.path}',
|
||||
]..addAll(snippet.args);
|
||||
...snippet.args,
|
||||
];
|
||||
print('Generating snippet for ${snippet.start?.filename}:${snippet.start?.line}');
|
||||
final ProcessResult process = _runSnippetsScript(args);
|
||||
if (process.exitCode != 0) {
|
||||
@@ -854,9 +856,11 @@ class Section {
|
||||
),
|
||||
);
|
||||
}
|
||||
return Section(<Line>[Line(prefix)]
|
||||
..addAll(codeLines)
|
||||
..add(Line(postfix)));
|
||||
return Section(<Line>[
|
||||
Line(prefix),
|
||||
...codeLines,
|
||||
Line(postfix),
|
||||
]);
|
||||
}
|
||||
Line get start => code.firstWhere((Line line) => line.filename != null);
|
||||
final List<Line> code;
|
||||
@@ -868,8 +872,8 @@ class Section {
|
||||
/// analyzed.
|
||||
class Snippet {
|
||||
Snippet({this.start, List<String> input, List<String> args, this.serial}) {
|
||||
this.input = <String>[]..addAll(input);
|
||||
this.args = <String>[]..addAll(args);
|
||||
this.input = input.toList();
|
||||
this.args = args.toList();
|
||||
}
|
||||
final Line start;
|
||||
final int serial;
|
||||
|
||||
@@ -260,7 +260,9 @@ Future<EvalResult> _evalCommand(String executable, List<String> arguments, {
|
||||
Future<void> _runFlutterAnalyze(String workingDirectory, {
|
||||
List<String> options = const <String>[],
|
||||
}) {
|
||||
return runCommand(flutter, <String>['analyze', '--dartdocs']..addAll(options),
|
||||
return runCommand(
|
||||
flutter,
|
||||
<String>['analyze', '--dartdocs', ...options],
|
||||
workingDirectory: workingDirectory,
|
||||
);
|
||||
}
|
||||
@@ -456,7 +458,10 @@ List<T> _deepSearch<T>(Map<T, Set<T>> map, T start, [ Set<T> seen ]) {
|
||||
final List<T> result = _deepSearch<T>(
|
||||
map,
|
||||
key,
|
||||
(seen == null ? <T>{start} : Set<T>.from(seen))..add(key),
|
||||
<T>{
|
||||
if (seen == null) start else ...seen,
|
||||
key,
|
||||
},
|
||||
);
|
||||
if (result != null) {
|
||||
result.insert(0, start);
|
||||
|
||||
@@ -381,14 +381,14 @@ class ArchiveCreator {
|
||||
|
||||
Future<String> _runFlutter(List<String> args, {Directory workingDirectory}) {
|
||||
return _processRunner.runProcess(
|
||||
<String>[_flutter]..addAll(args),
|
||||
<String>[_flutter, ...args],
|
||||
workingDirectory: workingDirectory ?? flutterRoot,
|
||||
);
|
||||
}
|
||||
|
||||
Future<String> _runGit(List<String> args, {Directory workingDirectory}) {
|
||||
return _processRunner.runProcess(
|
||||
<String>['git']..addAll(args),
|
||||
<String>['git', ...args],
|
||||
workingDirectory: workingDirectory ?? flutterRoot,
|
||||
);
|
||||
}
|
||||
@@ -574,14 +574,14 @@ class ArchivePublisher {
|
||||
}) async {
|
||||
if (platform.isWindows) {
|
||||
return _processRunner.runProcess(
|
||||
<String>['python', path.join(platform.environment['DEPOT_TOOLS'], 'gsutil.py'), '--']..addAll(args),
|
||||
<String>['python', path.join(platform.environment['DEPOT_TOOLS'], 'gsutil.py'), '--', ...args],
|
||||
workingDirectory: workingDirectory,
|
||||
failOk: failOk,
|
||||
);
|
||||
}
|
||||
|
||||
return _processRunner.runProcess(
|
||||
<String>['gsutil.py', '--']..addAll(args),
|
||||
<String>['gsutil.py', '--', ...args],
|
||||
workingDirectory: workingDirectory,
|
||||
failOk: failOk,
|
||||
);
|
||||
|
||||
@@ -3,7 +3,7 @@ description: Scripts which run on bots.
|
||||
|
||||
environment:
|
||||
# The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite.
|
||||
sdk: ">=2.2.0 <3.0.0"
|
||||
sdk: ">=2.2.2 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
path: 1.6.2
|
||||
|
||||
@@ -220,7 +220,7 @@ Future<void> _runToolCoverage() async {
|
||||
final List<String> testGroup = tests[i];
|
||||
await runCommand(
|
||||
dart,
|
||||
<String>[path.join('tool', 'tool_coverage.dart'), '--']..addAll(testGroup),
|
||||
<String>[path.join('tool', 'tool_coverage.dart'), '--', ...testGroup],
|
||||
workingDirectory: toolRoot,
|
||||
environment: <String, String>{
|
||||
'FLUTTER_ROOT': flutterRoot,
|
||||
@@ -791,7 +791,7 @@ Future<void> _runFlutterTest(String workingDirectory, {
|
||||
Map<String, String> environment,
|
||||
List<String> tests = const <String>[],
|
||||
}) async {
|
||||
final List<String> args = <String>['test']..addAll(options);
|
||||
final List<String> args = <String>['test', ...options];
|
||||
if (flutterTestArgs != null && flutterTestArgs.isNotEmpty)
|
||||
args.addAll(flutterTestArgs);
|
||||
|
||||
|
||||
@@ -35,8 +35,7 @@ class FakeProcessManager extends Mock implements ProcessManager {
|
||||
set fakeResults(Map<String, List<ProcessResult>> value) {
|
||||
_fakeResults = <String, List<ProcessResult>>{};
|
||||
for (String key in value.keys) {
|
||||
_fakeResults[key] = <ProcessResult>[]
|
||||
..addAll(value[key] ?? <ProcessResult>[ProcessResult(0, 0, '', '')]);
|
||||
_fakeResults[key] = (value[key] ?? <ProcessResult>[ProcessResult(0, 0, '', '')]).toList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -334,7 +334,7 @@ class ArchiveUnpublisher {
|
||||
bool failOk = false,
|
||||
bool confirm = false,
|
||||
}) async {
|
||||
final List<String> command = <String>['gsutil', '--']..addAll(args);
|
||||
final List<String> command = <String>['gsutil', '--', ...args];
|
||||
if (confirm) {
|
||||
return _processRunner.runProcess(
|
||||
command,
|
||||
@@ -358,7 +358,7 @@ class ArchiveUnpublisher {
|
||||
print(' $file');
|
||||
}
|
||||
}
|
||||
await _runGsUtil(<String>['rm']..addAll(files), failOk: true, confirm: confirmed);
|
||||
await _runGsUtil(<String>['rm', ...files], failOk: true, confirm: confirmed);
|
||||
}
|
||||
|
||||
Future<String> _cloudReplaceDest(String src, String dest) async {
|
||||
|
||||
@@ -17,7 +17,7 @@ Future<String> runFlutterAndQuit(List<String> args, Device device) async {
|
||||
print('run: starting...');
|
||||
final Process run = await startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['run', '--suppress-analytics']..addAll(args),
|
||||
<String>['run', '--suppress-analytics', ...args],
|
||||
isBot: false, // we just want to test the output, not have any debugging info
|
||||
);
|
||||
final List<String> stdout = <String>[];
|
||||
@@ -61,8 +61,13 @@ void main() {
|
||||
Future<void> checkMode(String mode, {bool releaseExpected = false, bool dynamic = false}) async {
|
||||
await inDirectory(appDir, () async {
|
||||
print('run: starting $mode test...');
|
||||
final List<String> args = <String>['--$mode']..addAll(dynamic ? <String>['--dynamic'] : const <String>[]);
|
||||
args.addAll(<String>['-d', device.deviceId, 'lib/build_mode.dart']);
|
||||
final List<String> args = <String>[
|
||||
'--$mode',
|
||||
if (dynamic) '--dynamic',
|
||||
'-d',
|
||||
device.deviceId,
|
||||
'lib/build_mode.dart',
|
||||
];
|
||||
final String stdout = await runFlutterAndQuit(args, device);
|
||||
if (!stdout.contains('>>> Release: $releaseExpected <<<')) {
|
||||
throw "flutter run --$mode ${dynamic ? '--dynamic ' : ''}didn't set kReleaseMode properly";
|
||||
|
||||
@@ -40,7 +40,7 @@ Future<TaskResult> createFlutterRunTask() async {
|
||||
await inDirectory<void>(flutterGalleryDir, () async {
|
||||
startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['run']..addAll(options),
|
||||
<String>['run', ...options],
|
||||
environment: null,
|
||||
);
|
||||
final Completer<void> finished = Completer<void>();
|
||||
|
||||
@@ -29,8 +29,9 @@ Future<void> main() async {
|
||||
deviceId,
|
||||
];
|
||||
final Process process = await startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['run']..addAll(options));
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['run', ...options],
|
||||
);
|
||||
|
||||
final Stream<String> lines = process.stdout
|
||||
.transform(utf8.decoder)
|
||||
|
||||
@@ -262,17 +262,17 @@ class AndroidDevice implements Device {
|
||||
|
||||
/// Executes [command] on `adb shell` and returns its exit code.
|
||||
Future<void> shellExec(String command, List<String> arguments, { Map<String, String> environment }) async {
|
||||
await adb(<String>['shell', command]..addAll(arguments), environment: environment);
|
||||
await adb(<String>['shell', command, ...arguments], environment: environment);
|
||||
}
|
||||
|
||||
/// Executes [command] on `adb shell` and returns its standard output as a [String].
|
||||
Future<String> shellEval(String command, List<String> arguments, { Map<String, String> environment }) {
|
||||
return adb(<String>['shell', command]..addAll(arguments), environment: environment);
|
||||
return adb(<String>['shell', command, ...arguments], environment: environment);
|
||||
}
|
||||
|
||||
/// Runs `adb` with the given [arguments], selecting this device.
|
||||
Future<String> adb(List<String> arguments, { Map<String, String> environment }) {
|
||||
return eval(adbPath, <String>['-s', deviceId]..addAll(arguments), environment: environment, canFail: false);
|
||||
return eval(adbPath, <String>['-s', deviceId, ...arguments], environment: environment, canFail: false);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -194,7 +194,7 @@ android {
|
||||
Future<ProcessResult> resultOfFlutterCommand(String command, List<String> options) {
|
||||
return Process.run(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>[command]..addAll(options),
|
||||
<String>[command, ...options],
|
||||
workingDirectory: rootPath,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ Future<Process> startProcess(
|
||||
environment ??= <String, String>{};
|
||||
environment['BOT'] = isBot ? 'true' : 'false';
|
||||
final Process process = await _processManager.start(
|
||||
<String>[executable]..addAll(arguments),
|
||||
<String>[executable, ...arguments],
|
||||
environment: environment,
|
||||
workingDirectory: workingDirectory ?? cwd,
|
||||
);
|
||||
|
||||
@@ -39,7 +39,7 @@ TaskFunction createHotModeTest() {
|
||||
{
|
||||
final Process process = await startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['run']..addAll(options),
|
||||
<String>['run', ...options],
|
||||
environment: null,
|
||||
);
|
||||
|
||||
@@ -93,7 +93,7 @@ TaskFunction createHotModeTest() {
|
||||
{
|
||||
final Process process = await startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['run']..addAll(options),
|
||||
<String>['run', ...options],
|
||||
environment: null,
|
||||
);
|
||||
final Completer<void> stdoutDone = Completer<void>();
|
||||
|
||||
@@ -65,7 +65,7 @@ Future<Process> _startFlutter({
|
||||
bool canFail = false,
|
||||
Map<String, String> environment,
|
||||
}) {
|
||||
final List<String> args = <String>['run']..addAll(options);
|
||||
final List<String> args = <String>['run', ...options];
|
||||
return startProcess(path.join(flutterDirectory.path, 'bin', 'flutter'), args, environment: environment);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ class FlutterProject {
|
||||
await inDirectory(directory, () async {
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>['--template=app', '--org', 'io.flutter.devicelab']..addAll(options)..add('plugintest'),
|
||||
options: <String>['--template=app', '--org', 'io.flutter.devicelab', ...options, 'plugintest'],
|
||||
);
|
||||
});
|
||||
return FlutterProject(directory, 'plugintest');
|
||||
|
||||
@@ -24,7 +24,7 @@ TaskFunction createRunWithoutLeakTest(dynamic dir) {
|
||||
await inDirectory<void>(dir, () async {
|
||||
final Process process = await startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['run']..addAll(options),
|
||||
<String>['run', ...options],
|
||||
environment: null,
|
||||
);
|
||||
final Completer<void> stdoutDone = Completer<void>();
|
||||
|
||||
@@ -37,7 +37,7 @@ TaskFunction createWebDevModeTest() {
|
||||
await packagesGet.exitCode;
|
||||
final Process process = await startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['run']..addAll(options),
|
||||
<String>['run', ...options],
|
||||
environment: <String, String>{
|
||||
'FLUTTER_WEB': 'true',
|
||||
},
|
||||
@@ -96,7 +96,7 @@ TaskFunction createWebDevModeTest() {
|
||||
{
|
||||
final Process process = await startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
<String>['run']..addAll(options),
|
||||
<String>['run', ...options],
|
||||
environment: <String, String>{
|
||||
'FLUTTER_WEB': 'true',
|
||||
},
|
||||
|
||||
@@ -21,7 +21,7 @@ void main() {
|
||||
}
|
||||
final String dart = path.absolute(path.join('..', '..', 'bin', 'cache', 'dart-sdk', 'bin', 'dart'));
|
||||
final ProcessResult scriptProcess = processManager.runSync(
|
||||
<String>[dart]..addAll(options)
|
||||
<String>[dart, ...options]
|
||||
);
|
||||
return scriptProcess;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,8 @@ class SnippetGenerator {
|
||||
}
|
||||
return <_ComponentTuple>[
|
||||
_ComponentTuple('description', description),
|
||||
]..addAll(components);
|
||||
...components,
|
||||
];
|
||||
}
|
||||
|
||||
String _loadFileAsUtf8(File file) {
|
||||
|
||||
@@ -6,7 +6,7 @@ homepage: https://github.com/flutter/flutter
|
||||
|
||||
environment:
|
||||
# The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite.
|
||||
sdk: ">=2.0.0-dev.68.0 <3.0.0"
|
||||
sdk: ">=2.2.2 <3.0.0"
|
||||
|
||||
dartdoc:
|
||||
# Exclude this package from the hosted API docs (Ironically...).
|
||||
|
||||
@@ -117,7 +117,7 @@ Future<void> main(List<String> arguments) async {
|
||||
// Verify which version of dartdoc we're using.
|
||||
final ProcessResult result = Process.runSync(
|
||||
pubExecutable,
|
||||
<String>[]..addAll(dartdocBaseArgs)..add('--version'),
|
||||
<String>[...dartdocBaseArgs, '--version'],
|
||||
workingDirectory: kDocsRoot,
|
||||
environment: pubEnvironment,
|
||||
);
|
||||
@@ -137,7 +137,8 @@ Future<void> main(List<String> arguments) async {
|
||||
// Generate the documentation.
|
||||
// We don't need to exclude flutter_tools in this list because it's not in the
|
||||
// recursive dependencies of the package defined at dev/docs/pubspec.yaml
|
||||
final List<String> dartdocArgs = <String>[]..addAll(dartdocBaseArgs)..addAll(<String>[
|
||||
final List<String> dartdocArgs = <String>[
|
||||
...dartdocBaseArgs,
|
||||
'--inject-html',
|
||||
'--header', 'styles.html',
|
||||
'--header', 'analytics.html',
|
||||
@@ -145,7 +146,8 @@ Future<void> main(List<String> arguments) async {
|
||||
'--header', 'snippets.html',
|
||||
'--header', 'opensearch.html',
|
||||
'--footer-text', 'lib/footer.html',
|
||||
'--allow-warnings-in-packages', <String>[
|
||||
'--allow-warnings-in-packages',
|
||||
<String>[
|
||||
'Flutter',
|
||||
'flutter',
|
||||
'platform_integration',
|
||||
@@ -198,7 +200,7 @@ Future<void> main(List<String> arguments) async {
|
||||
'--favicon=favicon.ico',
|
||||
'--package-order', 'flutter,Dart,platform_integration,flutter_test,flutter_driver',
|
||||
'--auto-include-dependencies',
|
||||
]);
|
||||
];
|
||||
|
||||
String quote(String arg) => arg.contains(' ') ? "'$arg'" : arg;
|
||||
print('Executing: (cd $kDocsRoot ; $pubExecutable ${dartdocArgs.map<String>(quote).join(' ')})');
|
||||
|
||||
@@ -3,7 +3,7 @@ description: Various repository development tools for flutter.
|
||||
|
||||
environment:
|
||||
# The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite.
|
||||
sdk: ">=2.2.0 <3.0.0"
|
||||
sdk: ">=2.2.2 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
archive: 2.0.10
|
||||
|
||||
Reference in New Issue
Block a user