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

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 {

examples/hacker_news_pwa/lib/src/item_detail_component.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ int countComments(Map comment) {
2323
@Component(
2424
selector: 'item-detail',
2525
templateUrl: 'item_detail_component.html',
26-
styleUrls: const ['item_detail_component.css'],
27-
directives: const [CommentComponent, ItemComponent, NgFor, NgIf],
26+
styleUrls: ['item_detail_component.css'],
27+
directives: [CommentComponent, ItemComponent, NgFor, NgIf],
2828
)
2929
class ItemDetailComponent implements OnActivate {
3030
final HackerNewsService _hackerNewsService;
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
import 'package:angular_router/angular_router.dart';
22

3-
final newsRoutePath = new RoutePath(
3+
final newsRoutePath = RoutePath(
44
path: '/',
55
additionalData: const {'feed': 'news'},
66
useAsDefault: true,
77
);
88

9-
final newRoutePath = new RoutePath(
9+
final newRoutePath = RoutePath(
1010
path: '/newest',
1111
additionalData: const {'feed': 'newest'},
1212
);
1313

14-
final showRoutePath = new RoutePath(
14+
final showRoutePath = RoutePath(
1515
path: '/show',
1616
additionalData: const {'feed': 'show'},
1717
);
1818

19-
final askRoutePath = new RoutePath(
19+
final askRoutePath = RoutePath(
2020
path: '/ask',
2121
additionalData: const {'feed': 'ask'},
2222
);
2323

24-
final jobsRoutePath = new RoutePath(
24+
final jobsRoutePath = RoutePath(
2525
path: '/jobs',
2626
additionalData: const {'feed': 'jobs'},
2727
);
2828

29-
final itemRoutePath = new RoutePath(path: '/item/:id');
29+
final itemRoutePath = RoutePath(path: '/item/:id');

examples/hacker_news_pwa/web/main.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import 'package:examples.hacker_news_pwa/hacker_news_service.dart';
1414
// ignore: uri_has_not_been_generated
1515
import 'main.template.dart' as ng;
1616

17-
@GenerateInjector(const [
17+
@GenerateInjector([
1818
// HTTP and Services.
19-
const FactoryProvider(HackerNewsService, getNewsService),
19+
FactoryProvider(HackerNewsService, getNewsService),
2020

2121
// SPA Router.
2222
routerProviders,
@@ -32,7 +32,7 @@ void main() {
3232
// This will make the perceived first load faster, and allow us to avoid
3333
// a flash-of-unstyled-content (Loading...) for the initial load, which hurts
3434
// PWA scores.
35-
_service = new HackerNewsService(defaultBaseUrl);
35+
_service = HackerNewsService(defaultBaseUrl);
3636
Future future;
3737
final path = window.location.pathname;
3838
if (window.location.search.isEmpty && !path.startsWith('/item')) {
@@ -44,7 +44,7 @@ void main() {
4444
}
4545

4646
// Install service worker.
47-
new pwa.Client();
47+
pwa.Client();
4848

4949
// Start app after fetched.
5050
future.then((_) {

examples/hacker_news_pwa/web/pwa.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import 'package:examples.hacker_news_pwa/hacker_news_service.dart';
44
import 'package:examples.hacker_news_pwa/pwa/offline_urls.g.dart' as offline;
55

66
void main() {
7-
final cache = new DynamicCache('hacker-news-service');
8-
new Worker()
7+
final cache = DynamicCache('hacker-news-service');
8+
Worker()
99
..offlineUrls = offline.offlineUrls
1010
..router.registerGetUrl(defaultBaseUrl, cache.networkFirst)
1111
..run(version: offline.lastModified);

examples/registration_form/lib/address/address_component.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ bool isPristine(NgControl control) => control.pristine;
2020

2121
@Directive(
2222
selector: 'material-auto-suggest-input[ngControl="state"]',
23-
providers: const [
24-
const ExistingProvider.forToken(NG_VALIDATORS, RequiredState)
25-
])
23+
providers: [ExistingProvider.forToken(NG_VALIDATORS, RequiredState)])
2624
class RequiredState implements Validator {
2725
@override
2826
Map<String, dynamic> validate(AbstractControl control) =>
@@ -31,7 +29,7 @@ class RequiredState implements Validator {
3129
: {'state': 'Please select a state from the list'};
3230
}
3331

34-
const List<String> states = const <String>[
32+
const List<String> states = <String>[
3533
'Alabama',
3634
'Alaska',
3735
'Arizona',

examples/registration_form/lib/root/root_component.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ class RootComponent {
3434
}
3535

3636
Person _createPerson(Map<String, dynamic> values) {
37-
return new Person(
37+
return Person(
3838
firstName: values['first-name'],
3939
lastName: values['last-name'],
4040
address: _createAddress(values['address']),
4141
);
4242
}
4343

4444
Address _createAddress(Map<String, dynamic> values) {
45-
return new Address(
45+
return Address(
4646
address1: values['address1'],
4747
address2: values['address2'],
4848
city: values['city'],

0 commit comments

Comments
 (0)