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

Run dartfmt fix over example apps to remove optional new/const. #1408

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/github_issues/lib/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class GithubService {
final payload = await HttpRequest.getString(_allIssuesEndpoint);
final issues = (json.decode(payload) as List).cast<Map<String, dynamic>>();
for (final issue in issues) {
yield new GithubIssue.parse(issue);
yield GithubIssue.parse(issue);
}
}
}
Expand Down Expand Up @@ -48,7 +48,7 @@ class GithubIssue {
});

factory GithubIssue.parse(Map<String, dynamic> json) {
return new GithubIssue(
return GithubIssue(
id: json['id'],
url: Uri.parse(json['html_url']),
title: json['title'],
Expand Down
8 changes: 4 additions & 4 deletions examples/github_issues/lib/ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import 'api.dart';

@Component(
selector: 'issue-list',
directives: const [
directives: [
NgFor,
NgIf,
IssueBodyComponent,
IssueTitleComponent,
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 {
Expand All @@ -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;
Expand Down Expand Up @@ -84,7 +84,7 @@ class IssueBodyComponent {
/// Renders [GithubIssue.title].
@Component(
selector: 'issue-title',
styles: const [
styles: [
r'''
a {
display: block;
Expand Down
4 changes: 2 additions & 2 deletions examples/github_issues/test/issue_body_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ void main() {

group('$IssueBodyComponent', () {
test('should properly render markdown', () async {
var testBed = new NgTestBed<IssueBodyComponent>();
var testBed = NgTestBed<IssueBodyComponent>();
var fixture = await testBed.create(beforeChangeDetection: (c) {
c.issue = new GithubIssue(
c.issue = GithubIssue(
description: '**Hello World**',
);
});
Expand Down
24 changes: 12 additions & 12 deletions examples/github_issues/test/issue_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'issue_list_test.template.dart' as ng;

@Component(
selector: 'test',
directives: const [IssueListComponent],
directives: [IssueListComponent],
template: r'<issue-list></issue-list>',
)
class ComplexTestComponent {}
Expand All @@ -26,26 +26,26 @@ void main() {

group('$IssueListComponent', () {
test('should properly render markdown', () async {
var stream = new StreamController<GithubIssue>();
var service = new MockGithubService();
var stream = StreamController<GithubIssue>();
var service = MockGithubService();
when(service.getIssues()).thenReturn(stream.stream);
var testBed = new NgTestBed<ComplexTestComponent>().addProviders([
var testBed = NgTestBed<ComplexTestComponent>().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',
Expand All @@ -54,7 +54,7 @@ void main() {
),
);
stream.add(
new GithubIssue(
GithubIssue(
id: 2,
url: Uri.parse('http://github.com'),
title: 'Second issue',
Expand All @@ -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];
Expand All @@ -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();
Expand All @@ -111,7 +111,7 @@ class IssueListPO {

Future<List<IssueItemPO>> _items() async => _root
.querySelectorAll('.github-issue')
.map((e) => new IssueItemPO(e))
.map((e) => IssueItemPO(e))
.toList();

Element get _expansion => _root.querySelector('.expansion');
Expand Down
6 changes: 3 additions & 3 deletions examples/github_issues/web/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'main.template.dart' as ng;

@Component(
selector: 'ng-app',
directives: const [
directives: [
IssueListComponent,
],
template: '<issue-list></issue-list>',
Expand All @@ -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);
});
}
16 changes: 8 additions & 8 deletions examples/hacker_news_pwa/lib/app_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 <style> tag.
Expand All @@ -26,27 +26,27 @@ class AppComponent {
static final jobsUrl = jobsRoutePath.toUrl();

static final routes = [
new RouteDefinition(
RouteDefinition(
routePath: newsRoutePath,
component: feed.FeedComponentNgFactory,
),
new RouteDefinition(
RouteDefinition(
routePath: newRoutePath,
component: feed.FeedComponentNgFactory,
),
new RouteDefinition(
RouteDefinition(
routePath: showRoutePath,
component: feed.FeedComponentNgFactory,
),
new RouteDefinition(
RouteDefinition(
routePath: askRoutePath,
component: feed.FeedComponentNgFactory,
),
new RouteDefinition(
RouteDefinition(
routePath: jobsRoutePath,
component: feed.FeedComponentNgFactory,
),
new RouteDefinition.defer(
RouteDefinition.defer(
routePath: itemRoutePath,
loader: () {
return item_detail.loadLibrary().then((_) {
Expand Down
6 changes: 3 additions & 3 deletions examples/hacker_news_pwa/lib/hacker_news_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'dart:html';
import 'package:angular/angular.dart';

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

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

Expand All @@ -21,12 +21,12 @@ class HackerNewsService {
Future<List<Map>> getFeed(String name, int page) {
final url = '$_baseUrl/$name/$page.json';
if (_cacheFeedKey == url) {
return new Future.value(_cacheFeedResult);
return Future.value(_cacheFeedResult);
}
return HttpRequest.getString(url).then((response) {
final List<dynamic> decoded = JSON.decode(response);
_cacheFeedKey = url;
return _cacheFeedResult = new List<Map>.from(decoded);
return _cacheFeedResult = List<Map>.from(decoded);
});
}

Expand Down
4 changes: 2 additions & 2 deletions examples/hacker_news_pwa/lib/src/comment_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'package:angular/security.dart';
@Component(
selector: 'comment',
templateUrl: 'comment_component.html',
styleUrls: const ['comment_component.css'],
directives: const [CommentComponent, NgFor, NgIf],
styleUrls: ['comment_component.css'],
directives: [CommentComponent, NgFor, NgIf],
changeDetection: ChangeDetectionStrategy.OnPush,
)
class CommentComponent {
Expand Down
4 changes: 2 additions & 2 deletions examples/hacker_news_pwa/lib/src/feed_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const itemsPerPage = 30;
@Component(
selector: 'feed',
templateUrl: 'feed_component.html',
styleUrls: const ['feed_component.css'],
directives: const [ItemComponent, NgFor, NgIf, routerDirectives],
styleUrls: ['feed_component.css'],
directives: [ItemComponent, NgFor, NgIf, routerDirectives],
encapsulation: ViewEncapsulation.None,
)
class FeedComponent implements OnActivate {
Expand Down
4 changes: 2 additions & 2 deletions examples/hacker_news_pwa/lib/src/item_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import 'routes.dart';
@Component(
selector: 'item',
templateUrl: 'item_component.html',
styleUrls: const ['item_component.css'],
directives: const [NgIf, RouterLink],
styleUrls: ['item_component.css'],
directives: [NgIf, RouterLink],
changeDetection: ChangeDetectionStrategy.OnPush,
)
class ItemComponent {
Expand Down
4 changes: 2 additions & 2 deletions examples/hacker_news_pwa/lib/src/item_detail_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ int countComments(Map comment) {
@Component(
selector: 'item-detail',
templateUrl: 'item_detail_component.html',
styleUrls: const ['item_detail_component.css'],
directives: const [CommentComponent, ItemComponent, NgFor, NgIf],
styleUrls: ['item_detail_component.css'],
directives: [CommentComponent, ItemComponent, NgFor, NgIf],
)
class ItemDetailComponent implements OnActivate {
final HackerNewsService _hackerNewsService;
Expand Down
12 changes: 6 additions & 6 deletions examples/hacker_news_pwa/lib/src/routes.dart
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import 'package:angular_router/angular_router.dart';

final newsRoutePath = new RoutePath(
final newsRoutePath = RoutePath(
path: '/',
additionalData: const {'feed': 'news'},
useAsDefault: true,
);

final newRoutePath = new RoutePath(
final newRoutePath = RoutePath(
path: '/newest',
additionalData: const {'feed': 'newest'},
);

final showRoutePath = new RoutePath(
final showRoutePath = RoutePath(
path: '/show',
additionalData: const {'feed': 'show'},
);

final askRoutePath = new RoutePath(
final askRoutePath = RoutePath(
path: '/ask',
additionalData: const {'feed': 'ask'},
);

final jobsRoutePath = new RoutePath(
final jobsRoutePath = RoutePath(
path: '/jobs',
additionalData: const {'feed': 'jobs'},
);

final itemRoutePath = new RoutePath(path: '/item/:id');
final itemRoutePath = RoutePath(path: '/item/:id');
8 changes: 4 additions & 4 deletions examples/hacker_news_pwa/web/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import 'package:examples.hacker_news_pwa/hacker_news_service.dart';
// ignore: uri_has_not_been_generated
import 'main.template.dart' as ng;

@GenerateInjector(const [
@GenerateInjector([
// HTTP and Services.
const FactoryProvider(HackerNewsService, getNewsService),
FactoryProvider(HackerNewsService, getNewsService),

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

// Install service worker.
new pwa.Client();
pwa.Client();

// Start app after fetched.
future.then((_) {
Expand Down
4 changes: 2 additions & 2 deletions examples/hacker_news_pwa/web/pwa.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'package:examples.hacker_news_pwa/hacker_news_service.dart';
import 'package:examples.hacker_news_pwa/pwa/offline_urls.g.dart' as offline;

void main() {
final cache = new DynamicCache('hacker-news-service');
new Worker()
final cache = DynamicCache('hacker-news-service');
Worker()
..offlineUrls = offline.offlineUrls
..router.registerGetUrl(defaultBaseUrl, cache.networkFirst)
..run(version: offline.lastModified);
Expand Down
6 changes: 2 additions & 4 deletions examples/registration_form/lib/address/address_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ bool isPristine(NgControl control) => control.pristine;

@Directive(
selector: 'material-auto-suggest-input[ngControl="state"]',
providers: const [
const ExistingProvider.forToken(NG_VALIDATORS, RequiredState)
])
providers: [ExistingProvider.forToken(NG_VALIDATORS, RequiredState)])
class RequiredState implements Validator {
@override
Map<String, dynamic> validate(AbstractControl control) =>
Expand All @@ -31,7 +29,7 @@ class RequiredState implements Validator {
: {'state': 'Please select a state from the list'};
}

const List<String> states = const <String>[
const List<String> states = <String>[
'Alabama',
'Alaska',
'Arizona',
Expand Down
4 changes: 2 additions & 2 deletions examples/registration_form/lib/root/root_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ class RootComponent {
}

Person _createPerson(Map<String, dynamic> values) {
return new Person(
return Person(
firstName: values['first-name'],
lastName: values['last-name'],
address: _createAddress(values['address']),
);
}

Address _createAddress(Map<String, dynamic> values) {
return new Address(
return Address(
address1: values['address1'],
address2: values['address2'],
city: values['city'],
Expand Down