diff --git a/deploy/effective-dart-rules/analysis_options.yaml b/deploy/effective-dart-rules/analysis_options.yaml index a894e6e416..ca2a1b79a2 100644 --- a/deploy/effective-dart-rules/analysis_options.yaml +++ b/deploy/effective-dart-rules/analysis_options.yaml @@ -28,7 +28,6 @@ linter: - slash_for_doc_comments - sort_constructors_first - sort_unnamed_constructors_first - - super_goes_last - test_types_in_equals - throw_in_finally # - type_annotate_public_apis diff --git a/deploy/effective-dart-rules/bin/main.dart b/deploy/effective-dart-rules/bin/main.dart index d8bc23037a..d50dff9256 100644 --- a/deploy/effective-dart-rules/bin/main.dart +++ b/deploy/effective-dart-rules/bin/main.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first import 'dart:async'; import 'dart:io'; @@ -14,13 +15,13 @@ Future main() async { "design.md" ]; List
sections = - filenames.map((name) => new Section(dirPath, name)).toList(); + filenames.map((name) => Section(dirPath, name)).toList(); for (var section in sections) { var lines = section.file.readAsLinesSync(); // Ignore the YAML front matter (can lead to false H3 elements. lines = lines.skip(1).skipWhile((line) => line.trim() != '---').toList(); - var document = new md.Document(); + var document = md.Document(); // Commented out the following line because the parseRefLinks has // disappeared. Unfortunately, that means I had to hand-patch the TOC @@ -32,19 +33,19 @@ Future main() async { var nodes = document.parseLines(lines); for (md.Element element in nodes.where((node) => node is md.Element)) { if (element.tag == "h2") { - var subsection = new Subsection(element); + var subsection = Subsection(element); section.subsections.add(subsection); continue; } if (element.tag == "h3") { - var rule = new Rule(element); + var rule = Rule(element); section.subsections.last.rules.add(rule); } } } - var outFile = new File(path.join(dirPath, "toc.md")); + var outFile = File(path.join(dirPath, "toc.md")); IOSink out; try { out = outFile.openWrite(); @@ -105,12 +106,11 @@ class Section { final Uri uri; final File file; final String name; - List subsections = new List(); + List subsections = List(); Section(String dirPath, String filename) - : file = new File(path.join(dirPath, filename)), - uri = Uri - .parse("/guides/language/effective-dart/") + : file = File(path.join(dirPath, filename)), + uri = Uri.parse("/guides/language/effective-dart/") .resolve(filename.split('.').first), name = "${filename[0].toUpperCase()}" "${filename.substring(1).split('.').first}"; @@ -119,7 +119,7 @@ class Section { class Subsection { final String name; final String fragment; - List rules = new List(); + List rules = List(); Subsection(md.Element element) : name = _concatenatedText(element), fragment = generateAnchorHash(element); @@ -129,9 +129,9 @@ class Subsection { String generateAnchorHash(md.Element element) => _concatenatedText(element) .toLowerCase() .trim() - .replaceFirst(new RegExp(r'^[^a-z]+'), '') - .replaceAll(new RegExp(r'[^a-z0-9 _-]'), '') - .replaceAll(new RegExp(r'\s'), '-'); + .replaceFirst(RegExp(r'^[^a-z]+'), '') + .replaceAll(RegExp(r'[^a-z0-9 _-]'), '') + .replaceAll(RegExp(r'\s'), '-'); /// Concatenates the text found in all the children of [element]. String _concatenatedText(md.Element element) => element.children @@ -139,5 +139,5 @@ String _concatenatedText(md.Element element) => element.children (child is md.Text) ? unescape(child.text) : _concatenatedText(child)) .join(''); -final _unescape = new HtmlUnescape(); +final _unescape = HtmlUnescape(); String unescape(String input) => _unescape.convert(input); diff --git a/examples/analysis_options.yaml b/examples/analysis_options.yaml index 31e47d116a..1d01c223bf 100644 --- a/examples/analysis_options.yaml +++ b/examples/analysis_options.yaml @@ -10,7 +10,6 @@ analyzer: linter: rules: - avoid_shadowing_type_parameters: false # TODO: reinstate? - annotate_overrides - await_only_futures - camel_case_types diff --git a/examples/httpserver/bin/basic_writer_server.dart b/examples/httpserver/bin/basic_writer_server.dart index b6d6aa0b95..e2e6223f9a 100644 --- a/examples/httpserver/bin/basic_writer_server.dart +++ b/examples/httpserver/bin/basic_writer_server.dart @@ -40,6 +40,6 @@ Future main() async { ..statusCode = HttpStatus.methodNotAllowed ..write("Unsupported request: ${req.method}."); } - response.close(); + await response.close(); } } diff --git a/examples/httpserver/bin/hello_world_server.dart b/examples/httpserver/bin/hello_world_server.dart index 22f79a0943..11b4ae42e0 100644 --- a/examples/httpserver/bin/hello_world_server.dart +++ b/examples/httpserver/bin/hello_world_server.dart @@ -18,9 +18,8 @@ Future main() async { // #docregion listen await for (HttpRequest request in server) { - request.response - ..write('Hello, world!') - ..close(); + request.response.write('Hello, world!'); + await request.response.close(); } // #enddocregion listen } diff --git a/examples/httpserver/bin/hello_world_server_secure.dart b/examples/httpserver/bin/hello_world_server_secure.dart index 83ce7319e8..7456f5a528 100644 --- a/examples/httpserver/bin/hello_world_server_secure.dart +++ b/examples/httpserver/bin/hello_world_server_secure.dart @@ -28,8 +28,7 @@ Future main() async { ); print('Listening on localhost:${server.port}'); await for (HttpRequest request in server) { - request.response - ..write('Hello, world!') - ..close(); + request.response.write('Hello, world!'); + await request.response.close(); } } diff --git a/examples/httpserver/bin/mini_file_server.dart b/examples/httpserver/bin/mini_file_server.dart index bd2f68806b..61d4c55e9d 100644 --- a/examples/httpserver/bin/mini_file_server.dart +++ b/examples/httpserver/bin/mini_file_server.dart @@ -34,9 +34,8 @@ Future main() async { } } else { print("Can't open ${targetFile.path}."); - req.response - ..statusCode = HttpStatus.notFound - ..close(); + req.response.statusCode = HttpStatus.notFound; + await req.response.close(); } } } diff --git a/examples/httpserver/bin/note_server.dart b/examples/httpserver/bin/note_server.dart index d5d90df5ec..da8b41de9c 100644 --- a/examples/httpserver/bin/note_server.dart +++ b/examples/httpserver/bin/note_server.dart @@ -30,7 +30,7 @@ Future listenForRequests(HttpServer requests) async { await for (HttpRequest request in requests) { switch (request.method) { case 'POST': - handlePost(request); + await handlePost(request); break; case 'OPTION': handleOptions(request); diff --git a/examples/misc/lib/articles/creating-streams/line_stream.dart b/examples/misc/lib/articles/creating-streams/line_stream.dart index 1e42a60288..5de0bf188a 100755 --- a/examples/misc/lib/articles/creating-streams/line_stream.dart +++ b/examples/misc/lib/articles/creating-streams/line_stream.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first import 'dart:async'; /// Combines incoming strings into a single stream and outputs its lines. diff --git a/examples/misc/lib/articles/io/io_http_server_file_test.dart b/examples/misc/lib/articles/io/io_http_server_file_test.dart index cb9ad039e1..ba08c781ee 100644 --- a/examples/misc/lib/articles/io/io_http_server_file_test.dart +++ b/examples/misc/lib/articles/io/io_http_server_file_test.dart @@ -4,7 +4,7 @@ import 'dart:io'; Future runServer(String basePath) async { final server = await HttpServer.bind('127.0.0.1', 8082); await for (HttpRequest request in server) { - handleRequest(basePath, request); + await handleRequest(basePath, request); } } diff --git a/examples/misc/lib/articles/io/io_http_server_test.dart b/examples/misc/lib/articles/io/io_http_server_test.dart index 084f33fd26..8656f5ddab 100644 --- a/examples/misc/lib/articles/io/io_http_server_test.dart +++ b/examples/misc/lib/articles/io/io_http_server_test.dart @@ -5,6 +5,6 @@ Future main() async { final server = await HttpServer.bind('127.0.0.1', 8082); await for (HttpRequest request in server) { request.response.write('Hello, world'); - request.response.close(); + await request.response.close(); } } diff --git a/examples/misc/lib/effective_dart/design_bad.dart b/examples/misc/lib/effective_dart/design_bad.dart index 3ac53af940..2227b82708 100644 --- a/examples/misc/lib/effective_dart/design_bad.dart +++ b/examples/misc/lib/effective_dart/design_bad.dart @@ -1,4 +1,4 @@ -// ignore_for_file: type_annotate_public_apis, unused_element, unused_local_variable, avoid_types_as_parameter_names +// ignore_for_file: type_annotate_public_apis, unused_element, unused_local_variable, avoid_types_as_parameter_names, sort_constructors_first import 'dart:async'; diff --git a/examples/misc/lib/effective_dart/design_good.dart b/examples/misc/lib/effective_dart/design_good.dart index 1bf5140cc2..76a5ac177b 100644 --- a/examples/misc/lib/effective_dart/design_good.dart +++ b/examples/misc/lib/effective_dart/design_good.dart @@ -1,4 +1,4 @@ -// ignore_for_file: type_annotate_public_apis, unused_element, unused_local_variable +// ignore_for_file: type_annotate_public_apis, unused_element, unused_local_variable, sort_constructors_first import 'dart:async'; import 'dart:collection'; @@ -122,7 +122,7 @@ void miscDeclAnalyzedButNotTested() { // #docregion annotate-declaration bool isEmpty(String parameter) { - bool result = parameter.length == 0; + bool result = parameter.isEmpty; return result; } // #enddocregion annotate-declaration diff --git a/examples/misc/lib/effective_dart/style_bad.dart b/examples/misc/lib/effective_dart/style_bad.dart index c9d1e2f392..4a56b3e12d 100644 --- a/examples/misc/lib/effective_dart/style_bad.dart +++ b/examples/misc/lib/effective_dart/style_bad.dart @@ -1,4 +1,4 @@ -// ignore_for_file: constant_identifier_names, non_constant_identifier_names, type_annotate_public_apis +// ignore_for_file: constant_identifier_names, non_constant_identifier_names, type_annotate_public_apis, curly_braces_in_flow_control_structures import 'dart:math'; // #docregion const-names diff --git a/examples/misc/lib/effective_dart/usage_bad.dart b/examples/misc/lib/effective_dart/usage_bad.dart index 2650ffaebb..0897de5dc2 100644 --- a/examples/misc/lib/effective_dart/usage_bad.dart +++ b/examples/misc/lib/effective_dart/usage_bad.dart @@ -1,4 +1,4 @@ -// ignore_for_file: avoid_init_to_null, empty_constructor_bodies, final_not_initialized_constructor_1, prefer_is_not_empty, sort_constructors_first, type_annotate_public_apis, type_init_formals, unnecessary_brace_in_string_interps, unnecessary_getters_setters, unused_element, unused_local_variable, prefer_equal_for_default_values, use_rethrow_when_possible +// ignore_for_file: avoid_init_to_null, empty_constructor_bodies, final_not_initialized_constructor_1, prefer_is_not_empty, sort_constructors_first, type_annotate_public_apis, type_init_formals, unnecessary_brace_in_string_interps, unnecessary_getters_setters, unused_element, unused_local_variable, prefer_equal_for_default_values, use_rethrow_when_possible, prefer_is_empty import 'dart:async'; import 'dart:io'; import 'dart:math'; diff --git a/examples/misc/lib/effective_dart/usage_good.dart b/examples/misc/lib/effective_dart/usage_good.dart index 08582faebf..e8d2c15217 100644 --- a/examples/misc/lib/effective_dart/usage_good.dart +++ b/examples/misc/lib/effective_dart/usage_good.dart @@ -1,4 +1,4 @@ -// ignore_for_file: type_annotate_public_apis, unused_element, unused_local_variable +// ignore_for_file: type_annotate_public_apis, unused_element, unused_local_variable, sort_constructors_first import 'dart:async'; import 'dart:io'; import 'dart:math'; diff --git a/examples/misc/lib/language_tour/async.dart b/examples/misc/lib/language_tour/async.dart index 378d6d1297..92803a3fe5 100644 --- a/examples/misc/lib/language_tour/async.dart +++ b/examples/misc/lib/language_tour/async.dart @@ -1,4 +1,4 @@ -// ignore_for_file: unused_element, unused_local_variable +// ignore_for_file: unused_element, unused_local_variable, unawaited_futures typedef Async0 = Future Function(); typedef Async1 = Future Function(dynamic); typedef Async2 = Future Function(dynamic, dynamic); diff --git a/examples/misc/lib/language_tour/classes/employee.dart b/examples/misc/lib/language_tour/classes/employee.dart index 7913f8f09b..22fd81a7f7 100644 --- a/examples/misc/lib/language_tour/classes/employee.dart +++ b/examples/misc/lib/language_tour/classes/employee.dart @@ -1,4 +1,4 @@ -// ignore_for_file: unnecessary_cast +// ignore_for_file: unnecessary_cast, sort_constructors_first Map getDefaultData() => {}; // stub diff --git a/examples/misc/lib/language_tour/classes/immutable_point.dart b/examples/misc/lib/language_tour/classes/immutable_point.dart index 2b2b5b2751..4d2c378652 100644 --- a/examples/misc/lib/language_tour/classes/immutable_point.dart +++ b/examples/misc/lib/language_tour/classes/immutable_point.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first class ImmutablePoint { static final ImmutablePoint origin = const ImmutablePoint(0, 0); diff --git a/examples/misc/lib/language_tour/classes/impostor.dart b/examples/misc/lib/language_tour/classes/impostor.dart index 0c1e74d212..99a7dfbcbf 100644 --- a/examples/misc/lib/language_tour/classes/impostor.dart +++ b/examples/misc/lib/language_tour/classes/impostor.dart @@ -1,4 +1,4 @@ -// ignore_for_file: annotate_overrides +// ignore_for_file: sort_constructors_first, annotate_overrides // A person. The implicit interface contains greet(). class Person { // In the interface, but visible only in this library. diff --git a/examples/misc/lib/language_tour/classes/logger.dart b/examples/misc/lib/language_tour/classes/logger.dart index 699effc6e5..8a899eaba8 100644 --- a/examples/misc/lib/language_tour/classes/logger.dart +++ b/examples/misc/lib/language_tour/classes/logger.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first // #docregion class Logger { final String name; diff --git a/examples/misc/lib/language_tour/classes/orchestra.dart b/examples/misc/lib/language_tour/classes/orchestra.dart index 9e67b5110a..77112f3745 100644 --- a/examples/misc/lib/language_tour/classes/orchestra.dart +++ b/examples/misc/lib/language_tour/classes/orchestra.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first // #docregion Musical mixin Musical { bool canPlayPiano = false; diff --git a/examples/misc/lib/language_tour/classes/point.dart b/examples/misc/lib/language_tour/classes/point.dart index 96e2fc16dd..dde050285e 100644 --- a/examples/misc/lib/language_tour/classes/point.dart +++ b/examples/misc/lib/language_tour/classes/point.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first // #docregion class-with-distanceTo import 'dart:math'; diff --git a/examples/misc/lib/language_tour/classes/point_alt.dart b/examples/misc/lib/language_tour/classes/point_alt.dart index 5969651d25..453435986a 100644 --- a/examples/misc/lib/language_tour/classes/point_alt.dart +++ b/examples/misc/lib/language_tour/classes/point_alt.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first /// Example of: /// /// - A constructor initializing fields in the body "the long way" diff --git a/examples/misc/lib/language_tour/classes/point_redirecting.dart b/examples/misc/lib/language_tour/classes/point_redirecting.dart index 430ea7b7a7..c5c4156c17 100644 --- a/examples/misc/lib/language_tour/classes/point_redirecting.dart +++ b/examples/misc/lib/language_tour/classes/point_redirecting.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first class Point { num x, y; diff --git a/examples/misc/lib/language_tour/classes/point_with_distance_field.dart b/examples/misc/lib/language_tour/classes/point_with_distance_field.dart index ae9e500d66..72eddd119f 100644 --- a/examples/misc/lib/language_tour/classes/point_with_distance_field.dart +++ b/examples/misc/lib/language_tour/classes/point_with_distance_field.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first import 'dart:math'; class Point { diff --git a/examples/misc/lib/language_tour/classes/point_with_distance_method.dart b/examples/misc/lib/language_tour/classes/point_with_distance_method.dart index a4e54e5eb7..9da6156ed3 100644 --- a/examples/misc/lib/language_tour/classes/point_with_distance_method.dart +++ b/examples/misc/lib/language_tour/classes/point_with_distance_method.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first import 'dart:math'; class Point { diff --git a/examples/misc/lib/language_tour/classes/rectangle.dart b/examples/misc/lib/language_tour/classes/rectangle.dart index 43352d783b..6431800cf3 100644 --- a/examples/misc/lib/language_tour/classes/rectangle.dart +++ b/examples/misc/lib/language_tour/classes/rectangle.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first class Rectangle { num left, top, width, height; diff --git a/examples/misc/lib/language_tour/classes/vector.dart b/examples/misc/lib/language_tour/classes/vector.dart index 9b810bf80a..cb90b7a3c7 100644 --- a/examples/misc/lib/language_tour/classes/vector.dart +++ b/examples/misc/lib/language_tour/classes/vector.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first // #docregion '' class Vector { final int x, y; diff --git a/examples/misc/lib/language_tour/metadata/todo.dart b/examples/misc/lib/language_tour/metadata/todo.dart index 0a23b8a654..db373d8324 100644 --- a/examples/misc/lib/language_tour/metadata/todo.dart +++ b/examples/misc/lib/language_tour/metadata/todo.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first library todo; class Todo { diff --git a/examples/misc/lib/language_tour/typedefs/sorted_collection_1.dart b/examples/misc/lib/language_tour/typedefs/sorted_collection_1.dart index 62bf838321..c5d848faca 100644 --- a/examples/misc/lib/language_tour/typedefs/sorted_collection_1.dart +++ b/examples/misc/lib/language_tour/typedefs/sorted_collection_1.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first class SortedCollection { Function compare; diff --git a/examples/misc/lib/language_tour/typedefs/sorted_collection_2.dart b/examples/misc/lib/language_tour/typedefs/sorted_collection_2.dart index 815a18ee7b..0552a6c9e4 100644 --- a/examples/misc/lib/language_tour/typedefs/sorted_collection_2.dart +++ b/examples/misc/lib/language_tour/typedefs/sorted_collection_2.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first typedef Compare = int Function(Object a, Object b); class SortedCollection { diff --git a/examples/misc/lib/library_tour/core/comparable.dart b/examples/misc/lib/library_tour/core/comparable.dart index f9a0514cf8..25461560a9 100644 --- a/examples/misc/lib/library_tour/core/comparable.dart +++ b/examples/misc/lib/library_tour/core/comparable.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first class Line implements Comparable { final int length; const Line(this.length); diff --git a/examples/misc/lib/library_tour/core/exception.dart b/examples/misc/lib/library_tour/core/exception.dart index 35f0bbdf20..eb3aff5f62 100644 --- a/examples/misc/lib/library_tour/core/exception.dart +++ b/examples/misc/lib/library_tour/core/exception.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first class FooException implements Exception { final String msg; diff --git a/examples/misc/lib/library_tour/core/hash_code.dart b/examples/misc/lib/library_tour/core/hash_code.dart index 2ae56eb6ce..6068562767 100644 --- a/examples/misc/lib/library_tour/core/hash_code.dart +++ b/examples/misc/lib/library_tour/core/hash_code.dart @@ -1,4 +1,4 @@ -// ignore_for_file: unrelated_type_equality_checks +// ignore_for_file: sort_constructors_first, unrelated_type_equality_checks // #docregion class Person { final String firstName, lastName; diff --git a/examples/misc/lib/pi_monte_carlo.dart b/examples/misc/lib/pi_monte_carlo.dart index 3ae4629917..4a5d4bcef5 100644 --- a/examples/misc/lib/pi_monte_carlo.dart +++ b/examples/misc/lib/pi_monte_carlo.dart @@ -1,4 +1,4 @@ -// ignore_for_file: type_annotate_public_apis +// ignore_for_file: sort_constructors_first, type_annotate_public_apis // WARNING: // diff --git a/examples/misc/lib/samples/spacecraft.dart b/examples/misc/lib/samples/spacecraft.dart index 35a9f5423b..b5f401edd4 100644 --- a/examples/misc/lib/samples/spacecraft.dart +++ b/examples/misc/lib/samples/spacecraft.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first // #docregion class class Spacecraft { String name; diff --git a/examples/misc/test/language_tour/async_test.dart b/examples/misc/test/language_tour/async_test.dart index 1ba9ef038f..7334e42644 100644 --- a/examples/misc/test/language_tour/async_test.dart +++ b/examples/misc/test/language_tour/async_test.dart @@ -1,4 +1,4 @@ -// ignore_for_file: type_annotate_public_apis +// ignore_for_file: type_annotate_public_apis, curly_braces_in_flow_control_structures import 'package:test/test.dart'; void main() { diff --git a/examples/misc/test/library_tour/core_test.dart b/examples/misc/test/library_tour/core_test.dart index 6156acf136..fd4b6d37d6 100644 --- a/examples/misc/test/library_tour/core_test.dart +++ b/examples/misc/test/library_tour/core_test.dart @@ -234,9 +234,9 @@ void main() { // Remove all elements from a list. fruits.clear(); - assert(fruits.length == 0); + assert(fruits.isEmpty); // #enddocregion List - assert(vegetables.length == 0); + assert(vegetables.isEmpty); }); test('indexOf', () { diff --git a/examples/misc/test/library_tour/io_test.dart b/examples/misc/test/library_tour/io_test.dart index a2585c7fea..d9f1695301 100644 --- a/examples/misc/test/library_tour/io_test.dart +++ b/examples/misc/test/library_tour/io_test.dart @@ -87,7 +87,7 @@ void main() { expect(logFile.readAsStringSync(), startsWith('FILE ACCESSED')); } finally { - logFile?.delete(); + await logFile?.delete(); } }); diff --git a/examples/strong/lib/bounded/my_collection.dart b/examples/strong/lib/bounded/my_collection.dart index 6229603e01..bd2f05c396 100644 --- a/examples/strong/lib/bounded/my_collection.dart +++ b/examples/strong/lib/bounded/my_collection.dart @@ -1,3 +1,4 @@ +// ignore_for_file: sort_constructors_first class C { final T collection; C(this.collection); diff --git a/examples/strong/lib/common_fixes_analysis.dart b/examples/strong/lib/common_fixes_analysis.dart index bfcc86ca7e..dbfc61eb85 100644 --- a/examples/strong/lib/common_fixes_analysis.dart +++ b/examples/strong/lib/common_fixes_analysis.dart @@ -1,5 +1,5 @@ // NOTE: Declarations in this file are analyzed but not tested. -// ignore_for_file: unused_element, unused_local_variable +// ignore_for_file: sort_constructors_first, unused_element, unused_local_variable import 'dart:html'; diff --git a/examples/strong/lib/common_problems_analysis.dart b/examples/strong/lib/common_problems_analysis.dart index 5eaa96d967..2a0e6ef4ea 100644 --- a/examples/strong/lib/common_problems_analysis.dart +++ b/examples/strong/lib/common_problems_analysis.dart @@ -3,7 +3,7 @@ // Include in this file only excerpts used to illustrate common problems. // The specific errors generated by the analyzer are included in the markdown. // -// ignore_for_file: unused_element, unused_local_variable +// ignore_for_file: sort_constructors_first, unused_element, unused_local_variable import 'dart:html'; diff --git a/examples/strong/lib/dart_1_my_list_hello_world.dart b/examples/strong/lib/dart_1_my_list_hello_world.dart index 90b0e181e4..2832dadf72 100644 --- a/examples/strong/lib/dart_1_my_list_hello_world.dart +++ b/examples/strong/lib/dart_1_my_list_hello_world.dart @@ -4,6 +4,7 @@ // ignore_for_file: invalid_override_from_base // ignore_for_file: invalid_override, type_annotate_public_apis // ignore_for_file: conflicting_generic_interfaces +// ignore_for_file: sort_constructors_first // #docregion MyList-and-main import 'dart:collection'; diff --git a/src/_articles/libraries/dart-io.md b/src/_articles/libraries/dart-io.md index 99d41de4d3..abeabe585e 100644 --- a/src/_articles/libraries/dart-io.md +++ b/src/_articles/libraries/dart-io.md @@ -304,7 +304,7 @@ Future main() async { final server = await HttpServer.bind('127.0.0.1', 8082); await for (HttpRequest request in server) { request.response.write('Hello, world'); - request.response.close(); + await request.response.close(); } } {% endprettify %} @@ -330,7 +330,7 @@ import 'dart:io'; Future runServer(String basePath) async { final server = await HttpServer.bind('127.0.0.1', 8082); await for (HttpRequest request in server) { - handleRequest(basePath, request); + await handleRequest(basePath, request); } } diff --git a/src/_guides/diagnostics.md b/src/_guides/diagnostics.md index 22c8473df6..a5d8ba39ce 100644 --- a/src/_guides/diagnostics.md +++ b/src/_guides/diagnostics.md @@ -267,7 +267,7 @@ against earlier versions of the SDK. #### Example In a package that defines the SDK constraint (in the pubspec.yaml file), -with a lower bound of less than 2.2: +with a lower bound of less than 2.2. For example: ```yaml environment: diff --git a/src/_guides/language/effective-dart/design.md b/src/_guides/language/effective-dart/design.md index 56d39c3832..f6e8f61073 100644 --- a/src/_guides/language/effective-dart/design.md +++ b/src/_guides/language/effective-dart/design.md @@ -961,7 +961,7 @@ the static declarative structure of the code and aren't "executed" at runtime. {% prettify dart %} bool isEmpty(String parameter) { - bool result = parameter.length == 0; + bool result = parameter.isEmpty; return result; } {% endprettify %} diff --git a/src/_guides/libraries/library-tour.md b/src/_guides/libraries/library-tour.md index 448b6521c7..c51f2d70f0 100644 --- a/src/_guides/libraries/library-tour.md +++ b/src/_guides/libraries/library-tour.md @@ -361,7 +361,7 @@ assert(fruits.length == 4); // Remove all elements from a list. fruits.clear(); -assert(fruits.length == 0); +assert(fruits.isEmpty); {% endprettify %} Use `indexOf()` to find the index of an object in a list: diff --git a/src/_tutorials/server/httpserver.md b/src/_tutorials/server/httpserver.md index c21bbcc4a6..43ddfd7ea9 100644 --- a/src/_tutorials/server/httpserver.md +++ b/src/_tutorials/server/httpserver.md @@ -133,9 +133,8 @@ Future main() async { print('Listening on localhost:${server.port}'); await for (HttpRequest request in server) { - request.response - ..write('Hello, world!') - ..close(); + request.response.write('Hello, world!'); + await request.response.close(); } } {% endprettify %} @@ -200,9 +199,8 @@ For each request received, the code sends a "Hello, world!" response. {% prettify dart %} await for (HttpRequest request in server) { - request.response - ..write('Hello, world!') - ..close(); + request.response.write('Hello, world!'); + await request.response.close(); } {% endprettify %}
hello_world_server.dart
@@ -677,7 +675,7 @@ Future main() async { ..statusCode = HttpStatus.methodNotAllowed ..write("Unsupported request: ${req.method}."); } - response.close(); + await response.close(); } } {% endprettify %} @@ -793,9 +791,8 @@ Future main() async { } } else { print("Can't open ${targetFile.path}."); - req.response - ..statusCode = HttpStatus.notFound - ..close(); + req.response.statusCode = HttpStatus.notFound; + await req.response.close(); } } } @@ -936,9 +933,8 @@ Future main() async { ); print('Listening on localhost:${server.port}'); await for (HttpRequest request in server) { - request.response - ..write('Hello, world!') - ..close(); + request.response.write('Hello, world!'); + await request.response.close(); } } {% endprettify %}