Dartlang 语法用 mixin 扩展类?

标签 dart

有人可以解释一下这种 Dart 语法吗?这是在某处记录的吗?

abstract class FixedLengthListBase<E> =
    ListBase<E> with FixedLengthListMixin<E>;

最佳答案

这是声明命名混合应用程序的语法。介绍in the "Mixins in Dart" article .

They are defined by a special form of class declaration that gives them a name and declares them equal to an application of a mixin to a superclass, given via a with clause.



这(几乎)与写作相同

abstract class FixedLengthListBase<E> extends
    ListBase<E> with FixedLengthListMixin<E>{}

技术上的区别在于,在这种情况下 FixedLengthListBase不是 mixin 应用程序本身,而是隐式的、未命名的 mixin 应用程序的抽象子类 ListBase<E> with FixedLengthListMixin<E>

关于Dartlang 语法用 mixin 扩展类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21552270/

相关文章:

dart - 如何在 flutter 中生成 'stacked card list view'?

android - Flutter path_provider错误-无法解析项目:path_provider_linux

android - Flutter从GetStorage列表中获取数据值

android - 如何在 flutter 中设置 Transform.translate() 动画的持续时间?

flutter - 在父 setState 之后子状态对象被替换(initState)而不是更新(didUpdateWidget)

user-interface - Flutter tabBar如何上下变化

listview - 我可以使用最初未声明的itemCount定义ListView Builder吗

flutter - 所有卡片的 TextField 值更改

flutter - 参数类型 'Color' 无法分配给参数类型“MaterialColor?”

sql - int 不是一种类型