如何“缺少具体的实现”?警告被压制了吗? [英] How can a "missing concrete implementation" warning be suppressed?

查看:122
本文介绍了如何“缺少具体的实现”?警告被压制了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该如何防止编译器引发以下警告

What can I do to prevent the compiler from throwing the following warning


缺少setter'MyClass.field'和getter的具体实现
'MyClass.field'

Missing concrete implementation of setter 'MyClass.field' and getter 'MyClass.field'

以下代码?

import 'package:mock/mock.dart';

class MyClass {
  String field;
}
@proxy
class MockMyClass extends Mock implements MyClass{}


推荐答案

实现 noSuchMethod(); 当类具有 noSuchMethod()它实现任何方法。我认为这也适用于getter / setter,因为它们只是特殊的方法(尽管从未尝试过)。另请参见 https://www.dartlang.org/文章/仿真功能/#与镜像的交互和否定方法

Implement noSuchMethod(); When a class has a noSuchMethod() it implements any method. I assume this applies to getter/setter as well because they are just special methods (never tried myself yet though). See also https://www.dartlang.org/articles/emulating-functions/#interactions-with-mirrors-and-nosuchmethod

这篇关于如何“缺少具体的实现”?警告被压制了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆