From 072a5d6c7767ab8b8fbe6f169d7fe348bcf62b7b Mon Sep 17 00:00:00 2001 From: Andrew Lorenzen Date: Thu, 14 Jun 2018 19:52:33 -0700 Subject: [PATCH] Run dartfmt fix over example apps to remove optional new/const. Skip any files that run on the VM (builder), until dart2 default is flipped. Closes #1408 PiperOrigin-RevId: 200660215 --- examples/github_issues/lib/api.dart | 4 ++-- examples/github_issues/lib/ui.dart | 8 +++---- .../github_issues/test/issue_body_test.dart | 4 ++-- .../github_issues/test/issue_list_test.dart | 24 +++++++++---------- examples/github_issues/web/main.dart | 6 ++--- .../hacker_news_pwa/lib/app_component.dart | 16 ++++++------- .../lib/hacker_news_service.dart | 6 ++--- .../lib/src/comment_component.dart | 4 ++-- .../lib/src/feed_component.dart | 4 ++-- .../lib/src/item_component.dart | 4 ++-- .../lib/src/item_detail_component.dart | 4 ++-- examples/hacker_news_pwa/lib/src/routes.dart | 12 +++++----- examples/hacker_news_pwa/web/main.dart | 8 +++---- examples/hacker_news_pwa/web/pwa.dart | 4 ++-- .../lib/address/address_component.dart | 6 ++--- .../lib/root/root_component.dart | 4 ++-- 16 files changed, 58 insertions(+), 60 deletions(-) diff --git a/examples/github_issues/lib/api.dart b/examples/github_issues/lib/api.dart index 754159d0a0..3ade98e596 100644 --- a/examples/github_issues/lib/api.dart +++ b/examples/github_issues/lib/api.dart @@ -15,7 +15,7 @@ class GithubService { final payload = await HttpRequest.getString(_allIssuesEndpoint); final issues = (json.decode(payload) as List).cast>(); for (final issue in issues) { - yield new GithubIssue.parse(issue); + yield GithubIssue.parse(issue); } } } @@ -48,7 +48,7 @@ class GithubIssue { }); factory GithubIssue.parse(Map json) { - return new GithubIssue( + return GithubIssue( id: json['id'], url: Uri.parse(json['html_url']), title: json['title'], diff --git a/examples/github_issues/lib/ui.dart b/examples/github_issues/lib/ui.dart index 3dd2b998a9..aa53880047 100644 --- a/examples/github_issues/lib/ui.dart +++ b/examples/github_issues/lib/ui.dart @@ -10,7 +10,7 @@ import 'api.dart'; @Component( selector: 'issue-list', - directives: const [ + directives: [ NgFor, NgIf, IssueBodyComponent, @@ -18,7 +18,7 @@ import 'api.dart'; MaterialProgressComponent, MaterialToggleComponent, ], - styleUrls: const ['src/ui/issue_list.scss.css'], + styleUrls: ['src/ui/issue_list.scss.css'], templateUrl: 'src/ui/issue_list.html', ) class IssueListComponent implements OnInit { @@ -31,7 +31,7 @@ class IssueListComponent implements OnInit { Timer _loadingTimer; IssueListComponent(this._github) { - _loadingTimer = new Timer.periodic(const Duration(milliseconds: 50), (_) { + _loadingTimer = Timer.periodic(const Duration(milliseconds: 50), (_) { progress += 10; if (progress > 100) { progress = 0; @@ -84,7 +84,7 @@ class IssueBodyComponent { /// Renders [GithubIssue.title]. @Component( selector: 'issue-title', - styles: const [ + styles: [ r''' a { display: block; diff --git a/examples/github_issues/test/issue_body_test.dart b/examples/github_issues/test/issue_body_test.dart index 11f9240daf..59d90165e1 100644 --- a/examples/github_issues/test/issue_body_test.dart +++ b/examples/github_issues/test/issue_body_test.dart @@ -14,9 +14,9 @@ void main() { group('$IssueBodyComponent', () { test('should properly render markdown', () async { - var testBed = new NgTestBed(); + var testBed = NgTestBed(); var fixture = await testBed.create(beforeChangeDetection: (c) { - c.issue = new GithubIssue( + c.issue = GithubIssue( description: '**Hello World**', ); }); diff --git a/examples/github_issues/test/issue_list_test.dart b/examples/github_issues/test/issue_list_test.dart index f30286f3f8..a7e99d7af1 100644 --- a/examples/github_issues/test/issue_list_test.dart +++ b/examples/github_issues/test/issue_list_test.dart @@ -15,7 +15,7 @@ import 'issue_list_test.template.dart' as ng; @Component( selector: 'test', - directives: const [IssueListComponent], + directives: [IssueListComponent], template: r'', ) class ComplexTestComponent {} @@ -26,26 +26,26 @@ void main() { group('$IssueListComponent', () { test('should properly render markdown', () async { - var stream = new StreamController(); - var service = new MockGithubService(); + var stream = StreamController(); + var service = MockGithubService(); when(service.getIssues()).thenReturn(stream.stream); - var testBed = new NgTestBed().addProviders([ + var testBed = NgTestBed().addProviders([ provide(GithubService, useValue: service), ]); var fixture = await testBed.create(); // NOT REQUIRED: We just want to slow down the test to see it. - await new Future.delayed(const Duration(seconds: 1)); + await Future.delayed(const Duration(seconds: 1)); // Get a handle to the list. - final list = new IssueListPO(fixture.rootElement); + final list = IssueListPO(fixture.rootElement); expect(await list.isLoading, isTrue); expect(await list.items, isEmpty); // Complete the RPC. await fixture.update((_) { stream.add( - new GithubIssue( + GithubIssue( id: 1, url: Uri.parse('http://github.com'), title: 'First issue', @@ -54,7 +54,7 @@ void main() { ), ); stream.add( - new GithubIssue( + GithubIssue( id: 2, url: Uri.parse('http://github.com'), title: 'Second issue', @@ -66,7 +66,7 @@ void main() { }); // NOT REQUIRED: We just want to slow down the test to see it. - await new Future.delayed(const Duration(seconds: 1)); + await Future.delayed(const Duration(seconds: 1)); // Try toggling an item. var row = (await list.items)[0]; @@ -81,14 +81,14 @@ void main() { ); // NOT REQUIRED: We just want to slow down the test to see it. - await new Future.delayed(const Duration(seconds: 1)); + await Future.delayed(const Duration(seconds: 1)); // Toggle again. await row.toggle(); expect(await row.isToggled, isFalse); // NOT REQUIRED: We just want to slow down the test to see it. - await new Future.delayed(const Duration(seconds: 1)); + await Future.delayed(const Duration(seconds: 1)); row = (await list.items)[1]; await row.toggle(); @@ -111,7 +111,7 @@ class IssueListPO { Future> _items() async => _root .querySelectorAll('.github-issue') - .map((e) => new IssueItemPO(e)) + .map((e) => IssueItemPO(e)) .toList(); Element get _expansion => _root.querySelector('.expansion'); diff --git a/examples/github_issues/web/main.dart b/examples/github_issues/web/main.dart index 6f40d81bf0..286bb2918c 100644 --- a/examples/github_issues/web/main.dart +++ b/examples/github_issues/web/main.dart @@ -6,7 +6,7 @@ import 'main.template.dart' as ng; @Component( selector: 'ng-app', - directives: const [ + directives: [ IssueListComponent, ], template: '', @@ -15,8 +15,8 @@ class NgAppComponent {} void main() { runApp(ng.NgAppComponentNgFactory, createInjector: ([parent]) { - return new Injector.map({ - GithubService: new GithubService(), + return Injector.map({ + GithubService: GithubService(), }, parent); }); } diff --git a/examples/hacker_news_pwa/lib/app_component.dart b/examples/hacker_news_pwa/lib/app_component.dart index 9192341a57..396f354b0c 100644 --- a/examples/hacker_news_pwa/lib/app_component.dart +++ b/examples/hacker_news_pwa/lib/app_component.dart @@ -11,8 +11,8 @@ import 'src/routes.dart'; @Component( selector: 'app', templateUrl: 'app_component.html', - directives: const [routerDirectives], - styleUrls: const ['app_component.css'], + directives: [routerDirectives], + styleUrls: ['app_component.css'], // Disabled. We use global styles that are used before the JavaScript loads. // // See web/index.html's