-
Notifications
You must be signed in to change notification settings - Fork 29.2k
Closed
Labels
a: null-safetySupport for Dart's null safety featureSupport for Dart's null safety featurea: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsp: pigeonrelated to pigeon messaging codegen toolrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.
Description
Here's a Pigeon-generated class:
class PositionMessage {
int? textureId;
int? position;
Object encode() {
final Map<Object?, Object?> pigeonMap = <Object?, Object?>{};
pigeonMap['textureId'] = textureId;
pigeonMap['position'] = position;
return pigeonMap;
}
static PositionMessage decode(Object message) {
final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>;
return PositionMessage()
..textureId = pigeonMap['textureId'] as int
..position = pigeonMap['position'] as int;
}
}
In sound null-safe mode, the decode
method might have null
values in textureId
and position
, so the cast as int
fails:
type 'Null' is not a subtype of type 'int' in type cast
package:video_player_platform_interface/messages.dart 121:44 PositionMessage.decode
package:video_player_platform_interface/messages.dart 339:30 VideoPlayerApi.position
Shouldn't the as
casts match the type of the attribute they're casting to? if int? textureId
, shouldn't the decode cast to: as int?
Steps to Reproduce
Attempt to run the video_player_platform_interface
tests in null-safe mode (flutter channel master
, for example):
- Clone this branch: https://github.com/ditman/plugins/tree/reversion-video_player_platform_interface-as-preview
cd YOUR_CLONE/packages/video_player/video_player_platform_interface
flutter test
Expected results:
All tests pass.
Actual results:
Some tests fail with the error described in this issue.
gaaclarke
Metadata
Metadata
Assignees
Labels
a: null-safetySupport for Dart's null safety featureSupport for Dart's null safety featurea: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsp: pigeonrelated to pigeon messaging codegen toolrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.