采纳答案成功!
向帮助你的同学说点啥吧!感谢那些助人为乐的人
显示说 The class ‘Study’ can’t be used as a mixin because it isn’t a mixin class nor a mixin class Test extends Person with Study{
Dart的不同版本对mixin的限制不同,为解决上述问题,我们可以通过mixin关键字来修饰一个mixin,去掉abstract class,以下是修改前后的代码对比:
修改前:
abstract class Study {
//抽象方法 : 没有方法体的方法称为抽象方法,不需要abstract关键字定义
void study();
//抽象类中可以包含有方法体的方法
void study2() {
print(
"study2"
);
}
class Test extends Person
with
Study {
Test(String name, int age) :
super
(name, age);
@override
void study() {
study2();
修改后:
mixin StudyMixin {
StudyMixin {
登录后可查看更多问答,登录/注册
全新Flutter从入门到进阶,实战仿携程网App
247 1
392 1
472 1
402 1
336 1
购课补贴联系客服咨询优惠详情
慕课网APP您的移动学习伙伴
扫描二维码关注慕课网微信公众号