且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Dart,在简单的类示例中,只能在初始化程序中访问静态成员

更新时间:2023-11-13 07:57:16

(我假设 BusInformationScreen 应该是 SimpleClass 的构造函数)

(I'm gonna assume BusInformationScreen is supposed to be the constructor for SimpleClass )

问题是

var output = ID;

您要设置输出的值在构建类之前。您可以在初始化列表中进行设置:

You're trying to set the value for output before the class has been constructed. You can set it in the initializer list instead :

  SimpleClass({this.ID}):
        output= ID;