Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/153.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 如何在flatter中检索当前类名?_Flutter - Fatal编程技术网

Flutter 如何在flatter中检索当前类名?

Flutter 如何在flatter中检索当前类名?,flutter,Flutter,我有一门课: class Dog { Dog() { print("Current classname is: ${this.className}"); } } 似乎不允许使用此.className。有类似的东西吗 this.runtimeType 或者只是 runtimeType 返回当前类的名称。如果要在类的开头而不是在生成方法中初始化变量(例如),方法如下: String className = (YourClass).toString();

我有一门课:

class Dog {

Dog() {
  print("Current classname is: ${this.className}");
}

}
似乎不允许使用此.className。有类似的东西吗

this.runtimeType
或者只是

runtimeType

返回当前类的名称。

如果要在类的开头而不是在生成方法中初始化变量(例如),方法如下:

String className = (YourClass).toString();