小编Dan*_*n R的帖子

如何创建一个 typedef 来表示具有命名字段的 Dart 记录?

我想定义一个 typedef 来表示带有命名字段的 Dart 记录,但不确定语法是什么。

下面的代码显示了如何定义Command表示具有两个位置字段的记录的 typedef:

/// A record holding:
/// * the name of an executable,
/// * the list of arguments.
typedef Command =(
  String executable,
  List<String> arguments,
);

extension Compose on Command {
  /// Joins the executable and the arguments.
  String get cmd => '${this.$1} ${this.$2.join(' ')}';
}
Run Code Online (Sandbox Code Playgroud)

typedef record named dart

4
推荐指数
1
解决办法
328
查看次数

标签 统计

dart ×1

named ×1

record ×1

typedef ×1