Skip to content

Nullability bug in _network_image.io.dart #88733

@egaga

Description

@egaga

Steps to Reproduce

The following code fails before throwing exception!

if (response.statusCode != HttpStatus.ok) {
// The network may be only temporarily unavailable, or the file will be
// added on the server later. Avoid having future calls to resolve
// fail to check the network again.
await response.drain<List<int>>();
throw image_provider.NetworkImageLoadException(statusCode: response.statusCode, uri: resolved);
}

Expected results:

This should be invoked:
throw image_provider.NetworkImageLoadException(statusCode: response.statusCode, uri: resolved);

Actual results:

I/flutter (18983): The following _CastError was thrown resolving an image codec:
I/flutter (18983): type 'Null' is not a subtype of type 'List<int>' in type cast
I/flutter (18983): 
I/flutter (18983): When the exception was thrown, this was the stack:
I/flutter (18983): #1      NetworkImage._loadAsync (package:flutter/src/painting/_network_image_io.dart:99:24)
I/flutter (18983): <asynchronous suspension>
Logs
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.5.2 20G95 darwin-x64, locale en-FI)
    • Flutter version 2.2.3 at /Users/egaga/dev/flutter
    • Framework revision f4abaa0735 (8 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: imagesLoading, displaying, rendering imagesa: null-safetySupport for Dart's null safety featureframeworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions