Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 1cf6d2f

Browse files
committed
code tweaks suggested by thso
1 parent 1b341fb commit 1cf6d2f

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

public/docs/_examples/dependency-injection/dart/lib/app_component.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,12 @@ import 'providers_component.dart';
4343
)
4444
class AppComponent {
4545
final UserService _userService;
46-
String title;
46+
final String title;
4747

4848
//#docregion ctor
49-
AppComponent(Config config, this._userService) {
50-
title = config.title;
51-
}
52-
49+
AppComponent(Config config, this._userService) : title = config.title;
5350
// #enddocregion ctor
51+
5452
bool get isAuthorized {
5553
return user.isAuthorized;
5654
}
@@ -64,6 +62,6 @@ class AppComponent {
6462
}
6563

6664
String get userInfo => 'Current user, ${user.name}, is'
67-
'${isAuthorized ? "" : " not"} authorized. ';
65+
'${isAuthorized ? "" : " not"} authorized. ';
6866
}
6967
// #enddocregion

public/docs/_examples/dependency-injection/dart/lib/app_component_1.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import 'heroes/heroes_component_1.dart';
1414
<my-heroes></my-heroes>''',
1515
directives: const [CarComponent, HeroesComponent])
1616
class AppComponent {
17-
var title = 'Dependency Injection';
17+
final String title = 'Dependency Injection';
1818
}
1919
// #enddocregion
2020

public/docs/_examples/dependency-injection/dart/lib/app_component_2.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ import 'logger_service.dart';
2525
const Provider('app.config', useValue: CONFIG)
2626
])
2727
class AppComponent {
28-
String title;
28+
final String title;
2929

3030
// #docregion ctor
31-
AppComponent(@Inject('app.config') Config config) {
32-
title = config.title;
33-
}
31+
AppComponent(@Inject('app.config') Config config)
32+
: title = config.title;
33+
// #enddocregion
3434
}
35-
// #enddocregion

public/docs/_examples/dependency-injection/dart/lib/car/car_component.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class CarComponent {
2323
final Car car;
2424

2525
CarComponent(this.car);
26+
2627
Car factoryCar = (new CarFactory()).createCar();
2728
Car injectorCar = useInjector();
2829
carNoDi.Car noDiCar = new carNoDi.Car();

public/docs/_examples/dependency-injection/dart/lib/car/car_factory.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import 'car.dart';
44
// BAD pattern!
55
class CarFactory {
66
Car createCar() {
7-
var car = new Car(createEngine(), createTires());
8-
car.description = 'Factory';
9-
return car;
7+
return new Car(createEngine(), createTires())
8+
..description = 'Factory';
109
}
1110

1211
Engine createEngine() => new Engine();

0 commit comments

Comments
 (0)