From f4bda4f434615809f88033335861171026e6b3c8 Mon Sep 17 00:00:00 2001 From: openapphub Date: Wed, 5 Nov 2025 15:55:50 +0800 Subject: [PATCH] fix: Example23 class When used as a mixin, it throws an error. Before Dart 2.1: Use a regular class without a constructor as a mixin. It is recommended to use mixin for the new project --- zh-cn/dart.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zh-cn/dart.md b/zh-cn/dart.md index fb52dd359a..2f4ba4d3d8 100644 --- a/zh-cn/dart.md +++ b/zh-cn/dart.md @@ -327,8 +327,9 @@ example22() { // Mixin 主要是用来和辅助的类共享方法的, // 这样单一继承就不会影响代码复用。 // Mixin 声明在类定义的 "with" 关键词后面。 +// 在 Dart 2.1 之前:把一个普通的、没有构造函数的 class 当作 mixin 使用。新项目推荐使用 mixin class Example23A {} -class Example23Utils { +mixin Example23Utils { addTwo(n1, n2) { return n1 + n2; }