Skip to content
This repository was archived by the owner on Sep 16, 2022. It is now read-only.

Commit 072a5d6

Browse files
alorenzenmatanlurey
authored andcommitted
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
1 parent 47dee4f commit 072a5d6

File tree

16 files changed

+58
-60
lines changed

16 files changed

+58
-60
lines changed

examples/github_issues/lib/api.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class GithubService {
1515
final payload = await HttpRequest.getString(_allIssuesEndpoint);
1616
final issues = (json.decode(payload) as List).cast<Map<String, dynamic>>();
1717
for (final issue in issues) {
18-
yield new GithubIssue.parse(issue);
18+
yield GithubIssue.parse(issue);
1919
}
2020
}
2121
}
@@ -48,7 +48,7 @@ class GithubIssue {
4848
});
4949

5050
factory GithubIssue.parse(Map<String, dynamic> json) {
51-
return new GithubIssue(
51+
return GithubIssue(
5252
id: json['id'],
5353
url: Uri.parse(json['html_url']),
5454
title: json['title'],

examples/github_issues/lib/ui.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import 'api.dart';
1010

1111
@Component(
1212
selector: 'issue-list',
13-
directives: const [
13+
directives: [
1414
NgFor,
1515
NgIf,
1616
IssueBodyComponent,
1717
IssueTitleComponent,
1818
MaterialProgressComponent,
1919
MaterialToggleComponent,
2020
],
21-
styleUrls: const ['src/ui/issue_list.scss.css'],
21+
styleUrls: ['src/ui/issue_list.scss.css'],
2222
templateUrl: 'src/ui/issue_list.html',
2323
)
2424
class IssueListComponent implements OnInit {
@@ -31,7 +31,7 @@ class IssueListComponent implements OnInit {
3131
Timer _loadingTimer;
3232

3333
IssueListComponent(this._github) {
34-
_loadingTimer = new Timer.periodic(const Duration(milliseconds: 50), (_) {
34+
_loadingTimer = Timer.periodic(const Duration(milliseconds: 50), (_) {
3535
progress += 10;
3636
if (progress > 100) {
3737
progress = 0;
@@ -84,7 +84,7 @@ class IssueBodyComponent {
8484
/// Renders [GithubIssue.title].
8585
@Component(
8686
selector: 'issue-title',
87-
styles: const [
87+
styles: [
8888
r'''
8989
a {
9090
display: block;

examples/github_issues/test/issue_body_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ void main() {
1414

1515
group('$IssueBodyComponent', () {
1616
test('should properly render markdown', () async {
17-
var testBed = new NgTestBed<IssueBodyComponent>();
17+
var testBed = NgTestBed<IssueBodyComponent>();
1818
var fixture = await testBed.create(beforeChangeDetection: (c) {
19-
c.issue = new GithubIssue(
19+
c.issue = GithubIssue(
2020
description: '**Hello World**',
2121
);
2222
});

examples/github_issues/test/issue_list_test.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import 'issue_list_test.template.dart' as ng;
1515

1616
@Component(
1717
selector: 'test',
18-
directives: const [IssueListComponent],
18+
directives: [IssueListComponent],
1919
template: r'<issue-list></issue-list>',
2020
)
2121
class ComplexTestComponent {}
@@ -26,26 +26,26 @@ void main() {
2626

2727
group('$IssueListComponent', () {
2828
test('should properly render markdown', () async {
29-
var stream = new StreamController<GithubIssue>();
30-
var service = new MockGithubService();
29+
var stream = StreamController<GithubIssue>();
30+
var service = MockGithubService();
3131
when(service.getIssues()).thenReturn(stream.stream);
32-
var testBed = new NgTestBed<ComplexTestComponent>().addProviders([
32+
var testBed = NgTestBed<ComplexTestComponent>().addProviders([
3333
provide(GithubService, useValue: service),
3434
]);
3535
var fixture = await testBed.create();
3636

3737
// NOT REQUIRED: We just want to slow down the test to see it.
38-
await new Future.delayed(const Duration(seconds: 1));
38+
await Future.delayed(const Duration(seconds: 1));
3939

4040
// Get a handle to the list.
41-
final list = new IssueListPO(fixture.rootElement);
41+
final list = IssueListPO(fixture.rootElement);
4242
expect(await list.isLoading, isTrue);
4343
expect(await list.items, isEmpty);
4444

4545
// Complete the RPC.
4646
await fixture.update((_) {
4747
stream.add(
48-
new GithubIssue(
48+
GithubIssue(
4949
id: 1,
5050
url: Uri.parse('http://github.com'),
5151
title: 'First issue',
@@ -54,7 +54,7 @@ void main() {
5454
),
5555
);
5656
stream.add(
57-
new GithubIssue(
57+
GithubIssue(
5858
id: 2,
5959
url: Uri.parse('http://github.com'),
6060
title: 'Second issue',
@@ -66,7 +66,7 @@ void main() {
6666
});
6767

6868
// NOT REQUIRED: We just want to slow down the test to see it.
69-
await new Future.delayed(const Duration(seconds: 1));
69+
await Future.delayed(const Duration(seconds: 1));
7070

7171
// Try toggling an item.
7272
var row = (await list.items)[0];
@@ -81,14 +81,14 @@ void main() {
8181
);
8282

8383
// NOT REQUIRED: We just want to slow down the test to see it.
84-
await new Future.delayed(const Duration(seconds: 1));
84+
await Future.delayed(const Duration(seconds: 1));
8585

8686
// Toggle again.
8787
await row.toggle();
8888
expect(await row.isToggled, isFalse);
8989

9090
// NOT REQUIRED: We just want to slow down the test to see it.
91-
await new Future.delayed(const Duration(seconds: 1));
91+
await Future.delayed(const Duration(seconds: 1));
9292

9393
row = (await list.items)[1];
9494
await row.toggle();
@@ -111,7 +111,7 @@ class IssueListPO {
111111

112112
Future<List<IssueItemPO>> _items() async => _root
113113
.querySelectorAll('.github-issue')
114-
.map((e) => new IssueItemPO(e))
114+
.map((e) => IssueItemPO(e))
115115
.toList();
116116

117117
Element get _expansion => _root.querySelector('.expansion');

examples/github_issues/web/main.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'main.template.dart' as ng;
66

77
@Component(
88
selector: 'ng-app',
9-
directives: const [
9+
directives: [
1010
IssueListComponent,
1111
],
1212
template: '<issue-list></issue-list>',
@@ -15,8 +15,8 @@ class NgAppComponent {}
1515

1616
void main() {
1717
runApp(ng.NgAppComponentNgFactory, createInjector: ([parent]) {
18-
return new Injector.map({
19-
GithubService: new GithubService(),
18+
return Injector.map({
19+
GithubService: GithubService(),
2020
}, parent);
2121
});
2222
}

examples/hacker_news_pwa/lib/app_component.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import 'src/routes.dart';
1111
@Component(
1212
selector: 'app',
1313
templateUrl: 'app_component.html',
14-
directives: const [routerDirectives],
15-
styleUrls: const ['app_component.css'],
14+
directives: [routerDirectives],
15+
styleUrls: ['app_component.css'],
1616
// Disabled. We use global styles that are used before the JavaScript loads.
1717
//
1818
// See web/index.html's <style> tag.
@@ -26,27 +26,27 @@ class AppComponent {
2626
static final jobsUrl = jobsRoutePath.toUrl();
2727

2828
static final routes = [
29-
new RouteDefinition(
29+
RouteDefinition(
3030
routePath: newsRoutePath,
3131
component: feed.FeedComponentNgFactory,
3232
),
33-
new RouteDefinition(
33+
RouteDefinition(
3434
routePath: newRoutePath,
3535
component: feed.FeedComponentNgFactory,
3636
),
37-
new RouteDefinition(
37+
RouteDefinition(
3838
routePath: showRoutePath,
3939
component: feed.FeedComponentNgFactory,
4040
),
41-
new RouteDefinition(
41+
RouteDefinition(
4242
routePath: askRoutePath,
4343
component: feed.FeedComponentNgFactory,
4444
),
45-
new RouteDefinition(
45+
RouteDefinition(
4646
routePath: jobsRoutePath,
4747
component: feed.FeedComponentNgFactory,
4848
),
49-
new RouteDefinition.defer(
49+
RouteDefinition.defer(
5050
routePath: itemRoutePath,
5151
loader: () {
5252
return item_detail.loadLibrary().then((_) {

examples/hacker_news_pwa/lib/hacker_news_service.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'dart:html';
55
import 'package:angular/angular.dart';
66

77
/// Represents the base URL for HTTP requests using [HackerNewsService].
8-
const baseUrl = const OpaqueToken<String>('baseUrl');
8+
const baseUrl = OpaqueToken<String>('baseUrl');
99

1010
const defaultBaseUrl = 'https://api.hnpwa.com/v0';
1111

@@ -21,12 +21,12 @@ class HackerNewsService {
2121
Future<List<Map>> getFeed(String name, int page) {
2222
final url = '$_baseUrl/$name/$page.json';
2323
if (_cacheFeedKey == url) {
24-
return new Future.value(_cacheFeedResult);
24+
return Future.value(_cacheFeedResult);
2525
}
2626
return HttpRequest.getString(url).then((response) {
2727
final List<dynamic> decoded = JSON.decode(response);
2828
_cacheFeedKey = url;
29-
return _cacheFeedResult = new List<Map>.from(decoded);
29+
return _cacheFeedResult = List<Map>.from(decoded);
3030
});
3131
}
3232

examples/hacker_news_pwa/lib/src/comment_component.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import 'package:angular/security.dart';
44
@Component(
55
selector: 'comment',
66
templateUrl: 'comment_component.html',
7-
styleUrls: const ['comment_component.css'],
8-
directives: const [CommentComponent, NgFor, NgIf],
7+
styleUrls: ['comment_component.css'],
8+
directives: [CommentComponent, NgFor, NgIf],
99
changeDetection: ChangeDetectionStrategy.OnPush,
1010
)
1111
class CommentComponent {

examples/hacker_news_pwa/lib/src/feed_component.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const itemsPerPage = 30;
1111
@Component(
1212
selector: 'feed',
1313
templateUrl: 'feed_component.html',
14-
styleUrls: const ['feed_component.css'],
15-
directives: const [ItemComponent, NgFor, NgIf, routerDirectives],
14+
styleUrls: ['feed_component.css'],
15+
directives: [ItemComponent, NgFor, NgIf, routerDirectives],
1616
encapsulation: ViewEncapsulation.None,
1717
)
1818
class FeedComponent implements OnActivate {

examples/hacker_news_pwa/lib/src/item_component.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import 'routes.dart';
66
@Component(
77
selector: 'item',
88
templateUrl: 'item_component.html',
9-
styleUrls: const ['item_component.css'],
10-
directives: const [NgIf, RouterLink],
9+
styleUrls: ['item_component.css'],
10+
directives: [NgIf, RouterLink],
1111
changeDetection: ChangeDetectionStrategy.OnPush,
1212
)
1313
class ItemComponent {

0 commit comments

Comments
 (0)