@@ -175,7 +175,7 @@ you must manually pass in all super constructor parameters.
175
175
If the super-constructor invocation includes positional arguments,
176
176
super-initializer parameters can't be positional.
177
177
178
- <? code-excerpt "super_initializer_parameters .dart (positional)" plaster="none"?>
178
+ <? code-excerpt "super_initializer_positional_parameters .dart (positional)" plaster="none"?>
179
179
``` dart
180
180
class Vector2d {
181
181
final double x;
@@ -211,7 +211,7 @@ between named super parameters (`super.y` in the next example)
211
211
and named arguments to the super constructor invocation
212
212
(` super.named(x: 0) ` ).
213
213
214
- <? code-excerpt "super_initializer_parameters .dart (named)" plaster="none"?>
214
+ <? code-excerpt "super_initializer_named_parameters .dart (named)" plaster="none"?>
215
215
``` dart
216
216
class Vector2d {
217
217
// ...
@@ -231,11 +231,9 @@ class Vector3d extends Vector2d {
231
231
232
232
### Redirecting constructors
233
233
234
- Sometimes a constructor's only serves to redirect to another
235
- constructor in the same class. A redirecting constructor's body is
236
- empty, with the constructor call
237
- (using ` this ` instead of the class name)
238
- appearing after a colon (:).
234
+ A constructor might redirect to another constructor in the same class.
235
+ A redirecting constructor has an empty body.
236
+ The constructor uses ` this ` instead of the class name after a colon (:).
239
237
240
238
<? code-excerpt "point_redirecting.dart"?>
241
239
``` dart
@@ -268,8 +266,7 @@ class ImmutablePoint {
268
266
```
269
267
270
268
Constant constructors don't always create constants.
271
- For details, see the section on
272
- [ using constructors] [ ] .
269
+ To learn more, consult the section on [ using constructors] [ ] .
273
270
274
271
### Factory constructors
275
272
@@ -292,10 +289,10 @@ You can also handle late initialization of a final variable
292
289
with [ ` late final ` ] [ late-final-ivar ] (carefully!).
293
290
:::
294
291
295
- In the following example includes two factory constructors.
292
+ The following example includes two factory constructors.
296
293
297
294
* ` Logger ` factory constructor returns objects from a cache.
298
- * The ` Logger.fromJson ` factory constructor initializes a final variable
295
+ * ` Logger.fromJson ` factory constructor initializes a final variable
299
296
from a JSON object.
300
297
301
298
<? code-excerpt "logger.dart (constructors)"?>
@@ -325,10 +322,10 @@ class Logger {
325
322
```
326
323
327
324
::: warning
328
- Factory constructors can't access to ` this ` .
325
+ Factory constructors can't access ` this ` .
329
326
:::
330
327
331
- Invoke a factory constructor just like you would any other constructor:
328
+ Use a factory constructor as any other constructor:
332
329
333
330
<? code-excerpt "logger.dart (logger)"?>
334
331
``` dart
@@ -366,18 +363,18 @@ class PointA {
366
363
### Use initializing formal parameters
367
364
368
365
To simplify the common pattern of assigning a constructor argument
369
- to an instance variable,
370
- Dart has * initializing formal parameters* .
366
+ to an instance variable, Dart has * initializing formal parameters* .
371
367
372
368
In the constructor declaration, include ` this.<propertyName> `
373
369
and omit the body. The ` this ` keyword refers to the current instance.
374
370
375
371
When the name conflict exists, use ` this ` .
376
372
Otherwise, Dart style omits the ` this ` .
377
- An exception exists for the generative constructor:
373
+ An exception exists for the generative constructor where
378
374
you must prefix the initializing formal parameter name with ` this ` .
379
375
380
- Certain constructors and parts of constructors can't access ` this ` :
376
+ As noted earlier in this guide, certain constructors
377
+ and certain parts of constructors can't access ` this ` . These include:
381
378
382
379
* Factory constructors
383
380
* The right-hand side of an initializer list
0 commit comments