Arguments.fromJson constructor

Arguments.fromJson(
  1. Map<String, dynamic> json, {
  2. required Variables variables,
})

Creates Arguments instance from JSON configuration.

Deserializes JSON configuration data to create a GitHub Arguments instance. Validates required fields and provides proper error handling for missing or invalid configuration.

Parameters:

  • json - JSON configuration map
  • variables - System variables for interpolation

Returns configured Arguments instance from JSON data.

Throws Exception if required fields are missing:

  • "file-path" is required
  • "repo-name" is required
  • "repo-owner" is required
  • "token" is required

Example JSON:

{
  "file-path": "/path/to/app.apk",
  "repo-name": "my-app",
  "repo-owner": "flutter-org",
  "token": "ghp_xxxxxxxxxxxxxxxxxxxx",
  "release-name": "v1.0.0",
  "release-body": "Initial release"
}

Implementation

factory Arguments.fromJson(
  Map<String, dynamic> json, {
  required Variables variables,
}) {
  if (json["file-path"] == null) throw Exception("file-path is required");
  if (json["repo-name"] == null) throw Exception("repo-name is required");
  if (json["repo-owner"] == null) throw Exception("repo-owner is required");
  if (json["token"] == null) throw Exception("token is required");

  return Arguments(
    variables,
    filePath: json['file-path'] as String,
    binaryType: '', // Provide a default or derive this value as needed
    repoName: json['repo-name'] as String,
    repoOwner: json['repo-owner'] as String,
    token: json['token'] as String,
    releaseName: json['release-name'] as String,
    releaseBody: json['release-body'] ?? "",
  );
}