[英]_$CustomClass shows error of `The return type 'Type' isn't a 'CustomClass', as defined by anonymous closure. `
I have add a new class TopicNew
and run flutter pub run build_runner build --delete-conflicting-outputs
in to a sample code from flutter_livestream_provider for learning. 我已经添加了一个新类
TopicNew
并运行flutter pub run build_runner build --delete-conflicting-outputs
到flutter_livestream_provider的示例代码中进行学习。
But I have no idea why my class shows error 但是我不知道为什么我的班级显示错误
import 'package:built_value/built_value.dart';
part 'topicNew.g.dart';
abstract class TopicNew implements Built<TopicNew, TopicNewBuilder> {
int get id;
String get name;
TopicNew._();
factory TopicNew([updates(TopicNewBuilder b)]) => _$TopicNew; #<- show error here
}
This is a syntax error. 这是语法错误。
Instead of: 代替:
=> _$TopicNew;
do: 做:
= _$TopicNew;
Factory constructors can be declared as 工厂构造函数可以声明为
factory Classname(int a) = OtherClass;
This syntax is a shorthand for 此语法是的简写
factory ClassName(int a) => OtherClass(a);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.