From 7c6ccb8ae65cf1783c76e07b71e24a12693fe8b7 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 11 Jul 2019 14:13:15 -0700 Subject: [PATCH] dartfmt --fix --- anagram/web/main.dart | 6 +++--- cmdline/bin/dcat.dart | 3 +-- cmdline/bin/dgrep.dart | 10 +++++----- futures/futures-api-catch-error/web/main.dart | 4 +++- httpserver/bin/basic_writer_client.dart | 2 +- httpserver/bin/basic_writer_server.dart | 2 +- httpserver/bin/mini_file_server.dart | 1 + httpserver/bin/note_server.dart | 3 ++- httpserver/test/httpserver_test.dart | 14 ++++++++------ portmanteaux/web/main.dart | 8 ++++---- portmanteaux_simple/web/main.dart | 7 ++++--- streams/last_positive/bin/main.dart | 2 +- streams/read_file/bin/main.dart | 4 ++-- todo/web/main.dart | 2 +- todo_with_delete/web/main.dart | 2 +- 15 files changed, 38 insertions(+), 32 deletions(-) diff --git a/anagram/web/main.dart b/anagram/web/main.dart index bc2feec..fec3925 100644 --- a/anagram/web/main.dart +++ b/anagram/web/main.dart @@ -12,7 +12,7 @@ import 'dart:math'; String scrabbleLetters = 'aaaaaaaaabbccddddeeeeeeeeeeeeffggghhiiiiiiiiijkllllmmnnnnnnooooooooppqrrrrrrssssttttttuuuuvvwwxyyz**'; -List buttons = new List(); +List buttons = List(); Element letterpile; Element result; ButtonElement clearButton; @@ -80,7 +80,7 @@ void newletters(Event e) { } void generateNewLetters() { - final indexGenerator = new Random(); + final indexGenerator = Random(); wordvalue = 0; value.text = ''; buttons.clear(); @@ -88,7 +88,7 @@ void generateNewLetters() { final letterIndex = indexGenerator.nextInt(scrabbleLetters.length); // Should remove the letter from scrabbleLetters to keep the // ratio correct. - buttons.add(new ButtonElement()); + buttons.add(ButtonElement()); buttons[i].classes.add("letter"); buttons[i].onClick.listen(moveLetter); buttons[i].text = scrabbleLetters[letterIndex]; diff --git a/cmdline/bin/dcat.dart b/cmdline/bin/dcat.dart index 840f2d8..c1010a7 100644 --- a/cmdline/bin/dcat.dart +++ b/cmdline/bin/dcat.dart @@ -25,8 +25,7 @@ ArgResults argResults; void main(List arguments) { exitCode = 0; //presume success - final parser = new ArgParser() - ..addFlag(lineNumber, negatable: false, abbr: 'n'); + final parser = ArgParser()..addFlag(lineNumber, negatable: false, abbr: 'n'); argResults = parser.parse(arguments); final paths = argResults.rest; diff --git a/cmdline/bin/dgrep.dart b/cmdline/bin/dgrep.dart index cf60a8b..33485d4 100644 --- a/cmdline/bin/dgrep.dart +++ b/cmdline/bin/dgrep.dart @@ -15,7 +15,7 @@ const followLinks = 'follow-links'; ArgResults argResults; void printMatch(File file, List lines, int i) { - final sb = new StringBuffer(); + final sb = StringBuffer(); if (argResults[recursive]) sb.write('${file.path}:'); if (argResults[lineNumber]) sb.write('${i + 1}:'); sb.write(lines[i]); @@ -40,7 +40,7 @@ Future searchFile(File file, List searchTerms) async { } Future main(List arguments) async { - final parser = new ArgParser() + final parser = ArgParser() ..addFlag(recursive, negatable: false, abbr: 'r') ..addFlag(lineNumber, negatable: false, abbr: 'n') ..addFlag(followLinks, negatable: false, abbr: 'S'); @@ -56,17 +56,17 @@ Future main(List arguments) async { final searchTerms = argResults.rest.sublist(0, argResults.rest.length - 1); if (await FileSystemEntity.isDirectory(searchPath)) { - final startingDir = new Directory(searchPath); + final startingDir = Directory(searchPath); await for (var entity in startingDir.list( recursive: argResults[recursive], followLinks: argResults[followLinks])) { if (entity is File) { await searchFile(entity, searchTerms); } else { - await searchFile(new File(searchPath), searchTerms); + await searchFile(File(searchPath), searchTerms); } } } else { - await searchFile(new File(searchPath), searchTerms); + await searchFile(File(searchPath), searchTerms); } } diff --git a/futures/futures-api-catch-error/web/main.dart b/futures/futures-api-catch-error/web/main.dart index 2f67fa5..7d9b864 100644 --- a/futures/futures-api-catch-error/web/main.dart +++ b/futures/futures-api-catch-error/web/main.dart @@ -10,7 +10,9 @@ final pre = PreElement(); void printDailyNewsDigest() { final future = gatherNewsReports(); - future.then((content) => pre.appendText(content)).catchError((e) => handleError(e)); + future + .then((content) => pre.appendText(content)) + .catchError((e) => handleError(e)); } void main() { diff --git a/httpserver/bin/basic_writer_client.dart b/httpserver/bin/basic_writer_client.dart index b1e977e..a45d64a 100644 --- a/httpserver/bin/basic_writer_client.dart +++ b/httpserver/bin/basic_writer_client.dart @@ -7,8 +7,8 @@ // to the server and prints the response. import 'dart:async'; -import 'dart:io'; import 'dart:convert'; +import 'dart:io'; String _host = InternetAddress.loopbackIPv4.host; String path = 'file.txt'; diff --git a/httpserver/bin/basic_writer_server.dart b/httpserver/bin/basic_writer_server.dart index 586d2be..466b191 100644 --- a/httpserver/bin/basic_writer_server.dart +++ b/httpserver/bin/basic_writer_server.dart @@ -7,8 +7,8 @@ // the file specified in the URI. import 'dart:async'; -import 'dart:io'; import 'dart:convert'; +import 'dart:io'; String _host = InternetAddress.loopbackIPv4.host; diff --git a/httpserver/bin/mini_file_server.dart b/httpserver/bin/mini_file_server.dart index b57b6a9..2e8bff6 100644 --- a/httpserver/bin/mini_file_server.dart +++ b/httpserver/bin/mini_file_server.dart @@ -9,6 +9,7 @@ import 'dart:async'; import 'dart:io'; + import 'package:path/path.dart' as p; var targetFile = diff --git a/httpserver/bin/note_server.dart b/httpserver/bin/note_server.dart index 8fe61f9..d616941 100644 --- a/httpserver/bin/note_server.dart +++ b/httpserver/bin/note_server.dart @@ -6,8 +6,9 @@ // Use note_taker.html to run the client. import 'dart:async'; -import 'dart:io'; import 'dart:convert' show utf8, json; +import 'dart:io'; + import 'package:path/path.dart' as p; int count = 0; diff --git a/httpserver/test/httpserver_test.dart b/httpserver/test/httpserver_test.dart index 38c46cd..3cd69e8 100644 --- a/httpserver/test/httpserver_test.dart +++ b/httpserver/test/httpserver_test.dart @@ -1,7 +1,9 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; + import 'package:test/test.dart'; + import '../bin/basic_file_server.dart' as basic_file_server; import '../bin/basic_writer_client.dart' as basic_writer_client; import '../bin/basic_writer_server.dart' as basic_writer_server; @@ -101,9 +103,9 @@ void main() { expect( () async => Future.any([ - server, - _test(), - ]), + server, + _test(), + ]), prints(''), ); }); @@ -121,9 +123,9 @@ void main() { expect( () async => Future.any([ - server, - _test(), - ]), + server, + _test(), + ]), prints('Wrote data for Han Solo.\n'), ); }); diff --git a/portmanteaux/web/main.dart b/portmanteaux/web/main.dart index 3c40ce8..94ba580 100644 --- a/portmanteaux/web/main.dart +++ b/portmanteaux/web/main.dart @@ -16,7 +16,7 @@ void main() { void makeRequest(Event e) { var path = 'https://dart.dev/f/portmanteaux.json'; - var httpRequest = new HttpRequest(); + var httpRequest = HttpRequest(); httpRequest ..open('GET', path) ..onLoadEnd.listen((e) => requestComplete(httpRequest)) @@ -28,10 +28,10 @@ void requestComplete(HttpRequest request) { final portmanteaux = (json.decode(request.responseText) as List).cast(); for (var i = 0; i < portmanteaux.length; i++) { - wordList.children.add(new LIElement()..text = portmanteaux[i]); + wordList.children.add(LIElement()..text = portmanteaux[i]); } } else { - wordList.children.add( - new LIElement()..text = 'Request failed, status=${request.status}'); + wordList.children + .add(LIElement()..text = 'Request failed, status=${request.status}'); } } diff --git a/portmanteaux_simple/web/main.dart b/portmanteaux_simple/web/main.dart index 6dad4d2..335c55c 100644 --- a/portmanteaux_simple/web/main.dart +++ b/portmanteaux_simple/web/main.dart @@ -26,12 +26,13 @@ Future makeRequest(Event e) async { } void processString(String jsonString) { - final portmanteaux = (json.decode(jsonString) as List).cast(); + final portmanteaux = + (json.decode(jsonString) as List).cast(); for (var i = 0; i < portmanteaux.length; i++) { - wordList.children.add(new LIElement()..text = portmanteaux[i]); + wordList.children.add(LIElement()..text = portmanteaux[i]); } } void handleError(Object error) { - wordList.children.add(new LIElement()..text = 'Request failed.'); + wordList.children.add(LIElement()..text = 'Request failed.'); } diff --git a/streams/last_positive/bin/main.dart b/streams/last_positive/bin/main.dart index 62e4d93..9d91e77 100644 --- a/streams/last_positive/bin/main.dart +++ b/streams/last_positive/bin/main.dart @@ -16,7 +16,7 @@ Future lastPositive(Stream stream) async { Future main() async { var data = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]; - var stream = new Stream.fromIterable(data); + var stream = Stream.fromIterable(data); var lastPos = await lastPositive(stream); print(lastPos); // 9 } diff --git a/streams/read_file/bin/main.dart b/streams/read_file/bin/main.dart index 945dbb3..340de0a 100644 --- a/streams/read_file/bin/main.dart +++ b/streams/read_file/bin/main.dart @@ -3,9 +3,9 @@ // All rights reserved. Use of this source code is governed // by a BSD-style license that can be found in the LICENSE file. -import 'dart:io'; import 'dart:async'; import 'dart:convert'; +import 'dart:io'; Future main(List args) async { if (args.isEmpty) { @@ -13,7 +13,7 @@ Future main(List args) async { return; } - var file = new File(args[0]); + var file = File(args[0]); var lines = utf8.decoder.bind(file.openRead()).transform(const LineSplitter()); await for (var line in lines) { diff --git a/todo/web/main.dart b/todo/web/main.dart index d9bdf9a..25a3ad1 100644 --- a/todo/web/main.dart +++ b/todo/web/main.dart @@ -16,7 +16,7 @@ void main() { } void addToDoItem(Event e) { - var newToDo = new LIElement(); + var newToDo = LIElement(); newToDo.text = toDoInput.value; toDoInput.value = ''; toDoList.children.add(newToDo); diff --git a/todo_with_delete/web/main.dart b/todo_with_delete/web/main.dart index 2d278cf..e499f34 100644 --- a/todo_with_delete/web/main.dart +++ b/todo_with_delete/web/main.dart @@ -19,7 +19,7 @@ void main() { } void addToDoItem(Event e) { - var newToDo = new LIElement(); + var newToDo = LIElement(); newToDo.text = toDoInput.value; newToDo.onClick.listen((e) => newToDo.remove()); toDoInput.value = '';