setCredentials function

void setCredentials(
  1. {String? path,
  2. Map? json}
)

Implementation

void setCredentials({String? path, Map? json}) {
  if (json != null) {
    config.sheetCredentials = json;
  } else if (path != null) {
    var credentialsString = openString(path);
    // if (credentialsString.isEmpty) {
    //   error(
    //       "ERROR: [gsheets:credentials_path:$path] doesn\'t exists or is empty.");
    //   exit(2);
    // }
    config.sheetCredentials = credentialsString;
  } else {
    final sysPath = Platform.environment['FTS_CREDENTIALS'];
    if (sysPath != null) {
      // print('spreadsheet id:\n - ' + magenta(config.sheetId!));
      trace(
          'fts detected ${magenta('FTS_CREDENTIALS')} variable in your system environment. Using it.');
      var credentialsString = openString(sysPath);
      config.sheetCredentials = credentialsString;
    }
  }
}