在Dart中将int转换为Uint8

我正在使用ffityed_data Dart库,并且此行代码不断出错,

 Uint8 START_OF_HEADER = 1 as Uint8;

我的错误:

  

类型'int'不是类型转换类型'Uint8'的子类型

我在这里做错了什么?另一个奇怪的事情是,我可以使用这些库编写此行代码,而我的IDE将会编译并且不会引发错误,即直到您使用该行代码为止。我正在使用Intellij版本2019.2.4

owen7758 回答:在Dart中将int转换为Uint8

您正在尝试在Dart中创建Uint8的实例,但这是不可能的-该类型只是标记。

/// [Uint8] is not constructible in the Dart code and serves purely as marker in
/// type signatures.
本文链接:https://www.f2er.com/3149781.html

大家都在问