Commit 8d533e3 1 parent bc31e98 commit 8d533e3 Copy full SHA for 8d533e3
File tree 2 files changed +10
-10
lines changed
examples/misc/lib/effective_dart
src/content/effective-dart
2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -358,22 +358,23 @@ class UploadException {
358
358
359
359
@override
360
360
String toString () {
361
- // #enddocregion null-check-promo
362
- final response = this .response;
363
- if (response != null ) {
361
+ // #enddocregion shadow-nullable-field
362
+ if (this .response case var response? ) {
364
363
return 'Could not complete upload to ${response .url } '
365
364
'(error code ${response .errorCode }): ${response .reason }.' ;
366
365
}
367
- // #docregion null-check-promo
368
- if (this .response case var response? ) {
366
+ // #enddocregion null-check-promo
367
+ // #docregion shadow-nullable-field
368
+ final response = this .response;
369
+ if (response != null ) {
369
370
return 'Could not complete upload to ${response .url } '
370
371
'(error code ${response .errorCode }): ${response .reason }.' ;
371
372
}
372
-
373
+ // #docregion null-check-promo
373
374
return 'Could not upload (no response).' ;
374
375
}
375
376
}
376
- // #enddocregion shadow-nullable-field
377
+ // #enddocregion shadow-nullable-field, null-check-promo
377
378
378
379
//----------------------------------------------------------------------------
379
380
Original file line number Diff line number Diff line change @@ -326,7 +326,6 @@ then it probably does make sense to have a separate boolean field.
326
326
327
327
328
328
### CONSIDER work arounds to bypass type promotion limitations
329
- (or, "...to enable type promotion")
330
329
331
330
Checking that a nullable variable is not equal to ` null ` promotes the variable
332
331
to a non-nullable type. That lets you access members on the variable and pass it
@@ -356,7 +355,7 @@ class UploadException {
356
355
return 'Could not complete upload to ${response.url} '
357
356
'(error code ${response.errorCode}): ${response.reason}.';
358
357
}
359
-
358
+ // ···
360
359
return 'Could not upload (no response).';
361
360
}
362
361
}
@@ -375,12 +374,12 @@ class UploadException {
375
374
376
375
@override
377
376
String toString() {
377
+ // ···
378
378
final response = this.response;
379
379
if (response != null) {
380
380
return 'Could not complete upload to ${response.url} '
381
381
'(error code ${response.errorCode}): ${response.reason}.';
382
382
}
383
-
384
383
return 'Could not upload (no response).';
385
384
}
386
385
}
You can’t perform that action at this time.
0 commit comments