Skip to content

Commit 8f00af8

Browse files
author
Tony Sansone
committed
Fixed code examples
1 parent 6311a74 commit 8f00af8

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

examples/misc/lib/language_tour/classes/point_alt.dart

-5
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ class PointB {
6262
// Initializing formal parameters can also be optional.
6363
PointB.optional([this.x = 0.0, this.y = 0.0]);
6464
PointB.named({required this.x, required this.y});
65-
66-
// Private fields cannot be used as named initializing formals.
67-
PointB.namedPrivate({required double x, required double y})
68-
: _x = x,
69-
_y = y;
7065
}
7166
// #enddocregion initialize-formal
7267

src/content/guides/whats-new.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ we made the following changes to this site:
560560
[Low-level HTML tutorials]: /web/get-started
561561

562562
[native types]: /interop/c-interop#interfacing-with-native-types
563-
[initializing formal parameters]: /language/constructors#initializing-formal-parameters
563+
[initializing formal parameters]: /language/constructors#use-initializing-formal-parameters
564564
[support for packages]: /tools/dartpad#library-support
565565
[asynchronous programming codelab]: /codelabs/async-await
566566
[why asynchronous code matters]: /codelabs/async-await#why-asynchronous-code-matters

src/content/language/classes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ can pass a static method as a parameter to a constant constructor.
369369
[`Type`]: {{site.dart-api}}/{{site.sdkInfo.channel}}/dart-core/Type-class.html
370370
[type test operator]: /language/operators#type-test-operators
371371
[Getters and setters]: /language/methods#getters-and-setters
372-
[initializer list]: /language/constructors#initializer-list
372+
[initializer list]: /language/constructors#use-an-initializer-list
373373
[factory constructor]: /language/constructors#factory-constructors
374374
[late-final-ivar]: /effective-dart/design#avoid-public-late-final-fields-without-initializers
375375
[nullable type]: /null-safety/understanding-null-safety#using-nullable-types

src/content/language/constructors.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,24 @@ class PointB {
420420
// Initializing formal parameters can also be optional.
421421
PointB.optional([this.x = 0.0, this.y = 0.0]);
422422
PointB.named({required this.x, required this.y});
423+
}
424+
```
425+
426+
Private fields can't be used as named initializing formals.
427+
428+
{% comment %}
429+
Don't attach the following example to a code excerpt.
430+
It doesn't work on purpose and will cause errors in CI.
431+
{% endcomment %}
432+
```dart
433+
class PointB {
434+
// ...
423435
424-
// Private fields cannot be used as named initializing formals.
425436
PointB.namedPrivate({required double x, required double y})
426437
: _x = x,
427438
_y = y;
439+
440+
// ...
428441
}
429442
```
430443

0 commit comments

Comments
 (0)