mirror of
https://github.com/flutter/flutter
synced 2024-08-27 20:10:11 +00:00
enable lints prefer_spread_collections and prefer_inlined_adds (#35189)
This commit is contained in:
parent
31cf49a9c9
commit
919dcf53f3
|
@ -33,11 +33,11 @@ analyzer:
|
|||
# Please see https://github.com/flutter/flutter/pull/24528 for details.
|
||||
sdk_version_async_exported_from_core: ignore
|
||||
exclude:
|
||||
- 'bin/cache/**'
|
||||
- "bin/cache/**"
|
||||
# the following two are relative to the stocks example and the flutter package respectively
|
||||
# see https://github.com/dart-lang/sdk/issues/28463
|
||||
- 'lib/i18n/stock_messages_*.dart'
|
||||
- 'lib/src/http/**'
|
||||
- "lib/i18n/stock_messages_*.dart"
|
||||
- "lib/src/http/**"
|
||||
|
||||
linter:
|
||||
rules:
|
||||
|
@ -143,7 +143,7 @@ linter:
|
|||
# - prefer_if_elements_to_conditional_expressions # not yet tested
|
||||
# - prefer_if_null_operators # not yet tested
|
||||
- prefer_initializing_formals
|
||||
# - prefer_inlined_adds # not yet tested
|
||||
- prefer_inlined_adds
|
||||
# - prefer_int_literals # not yet tested
|
||||
# - prefer_interpolation_to_compose_strings # not yet tested
|
||||
- prefer_is_empty
|
||||
|
@ -152,7 +152,7 @@ linter:
|
|||
# - prefer_mixin # https://github.com/dart-lang/language/issues/32
|
||||
# - prefer_null_aware_operators # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932
|
||||
- prefer_single_quotes
|
||||
# - prefer_spread_collections # not yet tested
|
||||
- prefer_spread_collections
|
||||
- prefer_typing_uninitialized_variables
|
||||
- prefer_void_to_null
|
||||
# - provide_deprecation_message # not yet tested
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -434,7 +434,8 @@ class CupertinoDemoTab2 extends StatelessWidget {
|
|||
child: ListView(
|
||||
children: <Widget>[
|
||||
Tab2Header(),
|
||||
]..addAll(buildTab2Conversation()),
|
||||
...buildTab2Conversation(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -493,11 +493,9 @@ class RecipeSheet extends StatelessWidget {
|
|||
),
|
||||
]
|
||||
),
|
||||
]..addAll(recipe.ingredients.map<TableRow>(
|
||||
(RecipeIngredient ingredient) {
|
||||
...recipe.ingredients.map<TableRow>((RecipeIngredient ingredient) {
|
||||
return _buildItemRow(ingredient.amount, ingredient.description);
|
||||
}
|
||||
))..add(
|
||||
}),
|
||||
TableRow(
|
||||
children: <Widget>[
|
||||
const SizedBox(),
|
||||
|
@ -506,12 +504,11 @@ class RecipeSheet extends StatelessWidget {
|
|||
child: Text('Steps', style: headingStyle),
|
||||
),
|
||||
]
|
||||
)
|
||||
)..addAll(recipe.steps.map<TableRow>(
|
||||
(RecipeStep step) {
|
||||
),
|
||||
...recipe.steps.map<TableRow>((RecipeStep step) {
|
||||
return _buildItemRow(step.duration ?? '', step.description);
|
||||
}
|
||||
)),
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -455,18 +455,14 @@ class GalleryOptionsPage extends StatelessWidget {
|
|||
const Divider(),
|
||||
const _Heading('Platform mechanics'),
|
||||
_PlatformItem(options, onOptionsChanged),
|
||||
]..addAll(
|
||||
_enabledDiagnosticItems(),
|
||||
)..addAll(
|
||||
<Widget>[
|
||||
const Divider(),
|
||||
const _Heading('Flutter gallery'),
|
||||
_ActionItem('About Flutter Gallery', () {
|
||||
showGalleryAboutDialog(context);
|
||||
}),
|
||||
_ActionItem('Send feedback', onSendFeedback),
|
||||
],
|
||||
),
|
||||
..._enabledDiagnosticItems(),
|
||||
const Divider(),
|
||||
const _Heading('Flutter gallery'),
|
||||
_ActionItem('About Flutter Gallery', () {
|
||||
showGalleryAboutDialog(context);
|
||||
}),
|
||||
_ActionItem('Send feedback', onSendFeedback),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ name: flutter_gallery
|
|||
|
||||
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:
|
||||
flutter:
|
||||
|
|
|
@ -2010,13 +2010,13 @@ abstract class RenderBox extends RenderObject {
|
|||
// TODO(jacobr): consider nesting the failures object so it is collapsible.
|
||||
throw FlutterError.fromParts(<DiagnosticsNode>[
|
||||
ErrorSummary('The intrinsic dimension methods of the $runtimeType class returned values that violate the intrinsic protocol contract.'),
|
||||
ErrorDescription('The following ${failures.length > 1 ? "failures" : "failure"} was detected:') // should this be tagged as an error or not?
|
||||
]..addAll(failures)
|
||||
..add(ErrorHint(
|
||||
ErrorDescription('The following ${failures.length > 1 ? "failures" : "failure"} was detected:'), // should this be tagged as an error or not?
|
||||
...failures,
|
||||
ErrorHint(
|
||||
'If you are not writing your own RenderBox subclass, then this is not\n'
|
||||
'your fault. Contact support: https://github.com/flutter/flutter/issues/new?template=BUG.md'
|
||||
))
|
||||
);
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -708,12 +708,13 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
|
|||
' http://api.flutter.dev/flutter/rendering/debugDumpRenderTree.html'
|
||||
),
|
||||
describeForError('The affected RenderFlex is', style: DiagnosticsTreeStyle.errorProperty),
|
||||
DiagnosticsProperty<dynamic>('The creator information is set to', debugCreator, style: DiagnosticsTreeStyle.errorProperty)
|
||||
]..addAll(addendum)
|
||||
..add(ErrorDescription(
|
||||
'If none of the above helps enough to fix this problem, please don\'t hesitate to file a bug:\n'
|
||||
' https://github.com/flutter/flutter/issues/new?template=BUG.md'
|
||||
)));
|
||||
DiagnosticsProperty<dynamic>('The creator information is set to', debugCreator, style: DiagnosticsTreeStyle.errorProperty),
|
||||
...addendum,
|
||||
ErrorDescription(
|
||||
'If none of the above helps enough to fix this problem, please don\'t hesitate to file a bug:\n'
|
||||
' https://github.com/flutter/flutter/issues/new?template=BUG.md'
|
||||
)
|
||||
]);
|
||||
}());
|
||||
totalFlex += childParentData.flex;
|
||||
lastFlexChild = child;
|
||||
|
|
|
@ -1204,15 +1204,16 @@ abstract class RenderSliver extends RenderObject {
|
|||
if (geometry.paintExtent > constraints.remainingPaintExtent) {
|
||||
throw FlutterError.fromParts(<DiagnosticsNode>[
|
||||
ErrorSummary('SliverGeometry has a paintOffset that exceeds the remainingPaintExtent from the constraints.'),
|
||||
describeForError('The render object whose geometry violates the constraints is the following')
|
||||
]..addAll(_debugCompareFloats(
|
||||
describeForError('The render object whose geometry violates the constraints is the following'),
|
||||
..._debugCompareFloats(
|
||||
'remainingPaintExtent', constraints.remainingPaintExtent,
|
||||
'paintExtent', geometry.paintExtent,
|
||||
))
|
||||
..add(ErrorDescription(
|
||||
'The paintExtent must cause the child sliver to paint within the viewport, and so '
|
||||
'cannot exceed the remainingPaintExtent.',
|
||||
)));
|
||||
),
|
||||
ErrorDescription(
|
||||
'The paintExtent must cause the child sliver to paint within the viewport, and so '
|
||||
'cannot exceed the remainingPaintExtent.',
|
||||
),
|
||||
]);
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
|
|
|
@ -344,10 +344,10 @@ class EditableText extends StatefulWidget {
|
|||
_strutStyle = strutStyle,
|
||||
keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline),
|
||||
inputFormatters = maxLines == 1
|
||||
? (
|
||||
<TextInputFormatter>[BlacklistingTextInputFormatter.singleLineFormatter]
|
||||
..addAll(inputFormatters ?? const Iterable<TextInputFormatter>.empty())
|
||||
)
|
||||
? <TextInputFormatter>[
|
||||
BlacklistingTextInputFormatter.singleLineFormatter,
|
||||
...inputFormatters ?? const Iterable<TextInputFormatter>.empty(),
|
||||
]
|
||||
: inputFormatters,
|
||||
showCursor = showCursor ?? !readOnly,
|
||||
super(key: key);
|
||||
|
|
|
@ -122,22 +122,22 @@ void main() {
|
|||
_checkEncoding<dynamic>(
|
||||
standard,
|
||||
Uint8List(253),
|
||||
<int>[8, 253]..addAll(List<int>.filled(253, 0)),
|
||||
<int>[8, 253, ...List<int>.filled(253, 0)],
|
||||
);
|
||||
_checkEncoding<dynamic>(
|
||||
standard,
|
||||
Uint8List(254),
|
||||
<int>[8, 254, 254, 0]..addAll(List<int>.filled(254, 0)),
|
||||
<int>[8, 254, 254, 0, ...List<int>.filled(254, 0)],
|
||||
);
|
||||
_checkEncoding<dynamic>(
|
||||
standard,
|
||||
Uint8List(0xffff),
|
||||
<int>[8, 254, 0xff, 0xff]..addAll(List<int>.filled(0xffff, 0)),
|
||||
<int>[8, 254, 0xff, 0xff, ...List<int>.filled(0xffff, 0)],
|
||||
);
|
||||
_checkEncoding<dynamic>(
|
||||
standard,
|
||||
Uint8List(0xffff + 1),
|
||||
<int>[8, 255, 0, 0, 1, 0]..addAll(List<int>.filled(0xffff + 1, 0)),
|
||||
<int>[8, 255, 0, 0, 1, 0, ...List<int>.filled(0xffff + 1, 0)],
|
||||
);
|
||||
});
|
||||
test('should encode and decode simple messages', () {
|
||||
|
|
|
@ -196,7 +196,8 @@ void main() {
|
|||
title: Text('App Bar'),
|
||||
),
|
||||
),
|
||||
]..addAll(slivers),
|
||||
...slivers,
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
|
|
|
@ -113,16 +113,17 @@ void main() {
|
|||
scrollMetrics: defaultMetrics,
|
||||
);
|
||||
|
||||
final List<ScrollMetrics> metricsList =
|
||||
<ScrollMetrics> [startingMetrics.copyWith(pixels: 0.01)]
|
||||
..addAll(List<ScrollMetrics>.generate(
|
||||
(maxExtent/viewportDimension).round(),
|
||||
(int index) => startingMetrics.copyWith(pixels: (index + 1) * viewportDimension),
|
||||
).where((ScrollMetrics metrics) => !metrics.outOfRange))
|
||||
..add(startingMetrics.copyWith(pixels: maxExtent - 0.01));
|
||||
final List<ScrollMetrics> metricsList = <ScrollMetrics> [
|
||||
startingMetrics.copyWith(pixels: 0.01),
|
||||
...List<ScrollMetrics>.generate(
|
||||
(maxExtent / viewportDimension).round(),
|
||||
(int index) => startingMetrics.copyWith(pixels: (index + 1) * viewportDimension),
|
||||
).where((ScrollMetrics metrics) => !metrics.outOfRange),
|
||||
startingMetrics.copyWith(pixels: maxExtent - 0.01),
|
||||
];
|
||||
|
||||
double lastCoefficient;
|
||||
for(ScrollMetrics metrics in metricsList) {
|
||||
for (ScrollMetrics metrics in metricsList) {
|
||||
painter.update(metrics, metrics.axisDirection);
|
||||
painter.paint(testCanvas, size);
|
||||
|
||||
|
|
|
@ -599,7 +599,8 @@ void _tests() {
|
|||
expandedHeight: 100.0,
|
||||
title: Text('AppBar'),
|
||||
),
|
||||
]..addAll(slivers),
|
||||
...slivers,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -824,7 +825,8 @@ void _tests() {
|
|||
expandedHeight: 100.0,
|
||||
title: Text('AppBar'),
|
||||
),
|
||||
]..addAll(slivers),
|
||||
...slivers,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -219,7 +219,7 @@ class AndroidDevice extends Device {
|
|||
_AndroidDevicePortForwarder _portForwarder;
|
||||
|
||||
List<String> adbCommandForDevice(List<String> args) {
|
||||
return <String>[getAdbPath(androidSdk), '-s', id]..addAll(args);
|
||||
return <String>[getAdbPath(androidSdk), '-s', id, ...args];
|
||||
}
|
||||
|
||||
String runAdbCheckedSync(
|
||||
|
|
|
@ -458,7 +458,7 @@ List<Font> _parsePackageFonts(
|
|||
));
|
||||
} else {
|
||||
packageFontAssets.add(FontAsset(
|
||||
Uri(pathSegments: <String>['packages', packageName]..addAll(assetUri.pathSegments)),
|
||||
Uri(pathSegments: <String>['packages', packageName, ...assetUri.pathSegments]),
|
||||
weight: fontAsset.weight,
|
||||
style: fontAsset.style,
|
||||
));
|
||||
|
@ -677,7 +677,7 @@ _Asset _resolveAsset(
|
|||
baseDir: assetsBaseDir,
|
||||
entryUri: packageName == null
|
||||
? assetUri // Asset from the current application.
|
||||
: Uri(pathSegments: <String>['packages', packageName]..addAll(assetUri.pathSegments)), // Asset from, and declared in $packageName.
|
||||
: Uri(pathSegments: <String>['packages', packageName, ...assetUri.pathSegments]), // Asset from, and declared in $packageName.
|
||||
relativeUri: assetUri,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,8 @@ class GenSnapshot {
|
|||
}) {
|
||||
final List<String> args = <String>[
|
||||
'--causal_async_stacks',
|
||||
]..addAll(additionalArgs);
|
||||
...additionalArgs,
|
||||
];
|
||||
|
||||
final String snapshotterPath = getSnapshotterPath(snapshotType);
|
||||
|
||||
|
@ -61,7 +62,7 @@ class GenSnapshot {
|
|||
// architecture.
|
||||
if (snapshotType.platform == TargetPlatform.ios) {
|
||||
final String hostArch = iosArch == IOSArch.armv7 ? '-i386' : '-x86_64';
|
||||
return runCommandAndStreamOutput(<String>['/usr/bin/arch', hostArch, snapshotterPath]..addAll(args));
|
||||
return runCommandAndStreamOutput(<String>['/usr/bin/arch', hostArch, snapshotterPath, ...args]);
|
||||
}
|
||||
|
||||
StringConverter outputFilter;
|
||||
|
@ -72,8 +73,7 @@ class GenSnapshot {
|
|||
outputFilter = (String line) => line != kStripWarning ? line : null;
|
||||
}
|
||||
|
||||
return runCommandAndStreamOutput(<String>[snapshotterPath]..addAll(args),
|
||||
mapFunction: outputFilter);
|
||||
return runCommandAndStreamOutput(<String>[snapshotterPath, ...args], mapFunction: outputFilter);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ class AOTSnapshotter {
|
|||
// If inputs and outputs have not changed since last run, skip the build.
|
||||
final Fingerprinter fingerprinter = Fingerprinter(
|
||||
fingerprintPath: '$depfilePath.fingerprint',
|
||||
paths: <String>[mainPath]..addAll(inputPaths)..addAll(outputPaths),
|
||||
paths: <String>[mainPath, ...inputPaths, ...outputPaths],
|
||||
properties: <String, String>{
|
||||
'buildMode': buildMode.toString(),
|
||||
'targetPlatform': platform.toString(),
|
||||
|
@ -422,7 +422,7 @@ class JITSnapshotter {
|
|||
// If inputs and outputs have not changed since last run, skip the build.
|
||||
final Fingerprinter fingerprinter = Fingerprinter(
|
||||
fingerprintPath: '$depfilePath.fingerprint',
|
||||
paths: <String>[mainPath]..addAll(inputPaths)..addAll(outputPaths),
|
||||
paths: <String>[mainPath, ...inputPaths, ...outputPaths],
|
||||
properties: <String, String>{
|
||||
'buildMode': buildMode.toString(),
|
||||
'targetPlatform': platform.toString(),
|
||||
|
|
|
@ -923,7 +923,7 @@ String _flattenNameNoSubdirs(String fileName) {
|
|||
|
||||
@visibleForTesting
|
||||
String flattenNameSubdirs(Uri url) {
|
||||
final List<String> pieces = <String>[url.host]..addAll(url.pathSegments);
|
||||
final List<String> pieces = <String>[url.host, ...url.pathSegments];
|
||||
final Iterable<String> convertedPieces = pieces.map<String>(_flattenNameNoSubdirs);
|
||||
return fs.path.joinAll(convertedPieces);
|
||||
}
|
||||
|
|
|
@ -127,10 +127,13 @@ class BuildAotCommand extends BuildSubCommand with TargetPlatformBasedDevelopmen
|
|||
if ((await Future.wait<int>(exitCodes.values)).every((int buildExitCode) => buildExitCode == 0)) {
|
||||
final Iterable<String> dylibs = iosBuilds.values.map<String>((String outputDir) => fs.path.join(outputDir, 'App.framework', 'App'));
|
||||
fs.directory(fs.path.join(outputPath, 'App.framework'))..createSync();
|
||||
await runCheckedAsync(<String>['lipo']
|
||||
..addAll(dylibs)
|
||||
..addAll(<String>['-create', '-output', fs.path.join(outputPath, 'App.framework', 'App')]),
|
||||
);
|
||||
await runCheckedAsync(<String>[
|
||||
'lipo',
|
||||
...dylibs,
|
||||
'-create',
|
||||
'-output',
|
||||
fs.path.join(outputPath, 'App.framework', 'App'),
|
||||
]);
|
||||
} else {
|
||||
status?.cancel();
|
||||
exitCodes.forEach((IOSArch iosArch, Future<int> exitCodeFuture) async {
|
||||
|
|
|
@ -182,7 +182,7 @@ class DriveCommand extends RunCommandBase {
|
|||
// if the application is `lib/foo/bar.dart`, the test file is expected to
|
||||
// be `test_driver/foo/bar_test.dart`.
|
||||
final String pathWithNoExtension = fs.path.withoutExtension(fs.path.joinAll(
|
||||
<String>[packageDir, 'test_driver']..addAll(parts.skip(1))));
|
||||
<String>[packageDir, 'test_driver', ...parts.skip(1)]));
|
||||
return '${pathWithNoExtension}_test${fs.path.extension(appFile)}';
|
||||
}
|
||||
}
|
||||
|
@ -297,13 +297,13 @@ Future<void> _runTests(List<String> testArgs, String observatoryUri) async {
|
|||
PackageMap.globalPackagesPath = fs.path.normalize(fs.path.absolute(PackageMap.globalPackagesPath));
|
||||
final String dartVmPath = fs.path.join(dartSdkPath, 'bin', 'dart');
|
||||
final int result = await runCommandAndStreamOutput(
|
||||
<String>[dartVmPath]
|
||||
..addAll(dartVmFlags)
|
||||
..addAll(testArgs)
|
||||
..addAll(<String>[
|
||||
'--packages=${PackageMap.globalPackagesPath}',
|
||||
'-rexpanded',
|
||||
]),
|
||||
<String>[
|
||||
dartVmPath,
|
||||
...dartVmFlags,
|
||||
...testArgs,
|
||||
'--packages=${PackageMap.globalPackagesPath}',
|
||||
'-rexpanded',
|
||||
],
|
||||
environment: <String, String>{'VM_SERVICE_URL': observatoryUri},
|
||||
);
|
||||
if (result != 0)
|
||||
|
|
|
@ -163,7 +163,7 @@ class PackagesTestCommand extends FlutterCommand {
|
|||
|
||||
@override
|
||||
Future<FlutterCommandResult> runCommand() async {
|
||||
await pub(<String>['run', 'test']..addAll(argResults.rest), context: PubContext.runTest, retry: false);
|
||||
await pub(<String>['run', 'test', ...argResults.rest], context: PubContext.runTest, retry: false);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ class PackagesForwardCommand extends FlutterCommand {
|
|||
|
||||
@override
|
||||
Future<FlutterCommandResult> runCommand() async {
|
||||
await pub(<String>[_commandName]..addAll(argResults.rest), context: PubContext.pubForward, retry: false);
|
||||
await pub(<String>[_commandName, ...argResults.rest], context: PubContext.pubForward, retry: false);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ Future<void> pubInteractively(
|
|||
|
||||
/// The command used for running pub.
|
||||
List<String> _pubCommand(List<String> arguments) {
|
||||
return <String>[ sdkBinaryName('pub') ]..addAll(arguments);
|
||||
return <String>[sdkBinaryName('pub'), ...arguments];
|
||||
}
|
||||
|
||||
/// The full environment used when running pub.
|
||||
|
|
|
@ -84,9 +84,10 @@ class FuchsiaKernelCompiler {
|
|||
];
|
||||
|
||||
final List<String> command = <String>[
|
||||
artifacts.getArtifactPath(Artifact.engineDartBinary),
|
||||
fuchsiaArtifacts.kernelCompiler.path,
|
||||
]..addAll(flags);
|
||||
artifacts.getArtifactPath(Artifact.engineDartBinary),
|
||||
fuchsiaArtifacts.kernelCompiler.path,
|
||||
...flags,
|
||||
];
|
||||
final Process process = await runCommand(command);
|
||||
final Status status = logger.startProgress(
|
||||
'Building Fuchsia application...',
|
||||
|
|
|
@ -90,11 +90,11 @@ class Xcode {
|
|||
}
|
||||
|
||||
Future<RunResult> cc(List<String> args) {
|
||||
return runCheckedAsync(<String>['xcrun', 'cc']..addAll(args));
|
||||
return runCheckedAsync(<String>['xcrun', 'cc', ...args]);
|
||||
}
|
||||
|
||||
Future<RunResult> clang(List<String> args) {
|
||||
return runCheckedAsync(<String>['xcrun', 'clang']..addAll(args));
|
||||
return runCheckedAsync(<String>['xcrun', 'clang', ...args]);
|
||||
}
|
||||
|
||||
String getSimulatorPath() {
|
||||
|
|
|
@ -17,7 +17,7 @@ void main() {
|
|||
Cache.disableLocking();
|
||||
|
||||
Future<void> runCommand(Iterable<String> flags, _TestMethod testMethod) async {
|
||||
final List<String> args = <String>['test']..addAll(flags);
|
||||
final List<String> args = <String>['test', ...flags];
|
||||
final _TestCommand command = _TestCommand(testMethod);
|
||||
await createTestCommandRunner(command).run(args);
|
||||
}
|
||||
|
|
|
@ -1169,10 +1169,11 @@ Future<void> _analyzeProject(String workingDir) async {
|
|||
'flutter_tools.dart',
|
||||
));
|
||||
|
||||
final List<String> args = <String>[]
|
||||
..addAll(dartVmFlags)
|
||||
..add(flutterToolsPath)
|
||||
..add('analyze');
|
||||
final List<String> args = <String>[
|
||||
...dartVmFlags,
|
||||
flutterToolsPath,
|
||||
'analyze',
|
||||
];
|
||||
|
||||
final ProcessResult exec = await Process.run(
|
||||
'$dartSdkPath/bin/dart',
|
||||
|
@ -1196,21 +1197,22 @@ Future<void> _runFlutterTest(Directory workingDir, { String target }) async {
|
|||
// files anymore.
|
||||
await Process.run(
|
||||
'$dartSdkPath/bin/dart',
|
||||
<String>[]
|
||||
..addAll(dartVmFlags)
|
||||
..add(flutterToolsPath)
|
||||
..addAll(<String>['packages', 'get']),
|
||||
<String>[
|
||||
...dartVmFlags,
|
||||
flutterToolsPath,
|
||||
'packages',
|
||||
'get',
|
||||
],
|
||||
workingDirectory: workingDir.path,
|
||||
);
|
||||
|
||||
final List<String> args = <String>[]
|
||||
..addAll(dartVmFlags)
|
||||
..add(flutterToolsPath)
|
||||
..add('test')
|
||||
..add('--no-color');
|
||||
if (target != null) {
|
||||
args.add(target);
|
||||
}
|
||||
final List<String> args = <String>[
|
||||
...dartVmFlags,
|
||||
flutterToolsPath,
|
||||
'test',
|
||||
'--no-color',
|
||||
if (target != null) target,
|
||||
];
|
||||
|
||||
final ProcessResult exec = await Process.run(
|
||||
'$dartSdkPath/bin/dart',
|
||||
|
|
|
@ -172,13 +172,14 @@ Future<ProcessResult> _runFlutterTest(
|
|||
if (!testFile.existsSync())
|
||||
fail('missing test file: $testFile');
|
||||
|
||||
final List<String> args = <String>[]
|
||||
..addAll(dartVmFlags)
|
||||
..add(fs.path.absolute(fs.path.join('bin', 'flutter_tools.dart')))
|
||||
..add('test')
|
||||
..add('--no-color')
|
||||
..addAll(extraArgs)
|
||||
..add(testFilePath);
|
||||
final List<String> args = <String>[
|
||||
...dartVmFlags,
|
||||
fs.path.absolute(fs.path.join('bin', 'flutter_tools.dart')),
|
||||
'test',
|
||||
'--no-color',
|
||||
...extraArgs,
|
||||
testFilePath
|
||||
];
|
||||
|
||||
while (_testExclusionLock != null)
|
||||
await _testExclusionLock;
|
||||
|
|
|
@ -131,7 +131,7 @@ Future<String> createProject(Directory temp, { List<String> arguments }) async {
|
|||
final String projectPath = fs.path.join(temp.path, 'flutter_project');
|
||||
final CreateCommand command = CreateCommand();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(command);
|
||||
await runner.run(<String>['create']..addAll(arguments)..add(projectPath));
|
||||
await runner.run(<String>['create', ...arguments, projectPath]);
|
||||
return projectPath;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue