fromJson static method

StackCommand? fromJson(
  1. Map<String, Object?> json
)

Implementation

static StackCommand? fromJson(Map<String, Object?> json) {
  var id = json['id'];
  var label = json['label'];
  var run = StackRun.fromJson(json['run'] ?? json['command']);
  if (id is! String || label is! String || run == null) return null;
  return StackCommand(
    id,
    label,
    run,
    description: json['description'] as String?,
    danger: json['danger'] == true,
    argument: json['argument'] as String?,
    timeout: json['timeout'] is int
        ? Duration(milliseconds: json['timeout']! as int)
        : null,
  );
}