vars method

  1. @override
void vars(
  1. Map<String, dynamic>? obj
)
override

Implementation

@override
void vars(Map<String, dynamic>? obj) {
  var inspectVarsPath = Platform.environment['INSPECT_VARS'];
  if (inspectVarsPath == null || inspectVarsPath.isEmpty || obj == null) {
    return;
  }

  var json = jsonEncode(obj);
  var varsPath = inspectVarsPath.replaceAll('\\', '/');
  if (varsPath.contains('/')) {
    var dir = dirname(varsPath);
    if (!Directory(dir).existsSync()) {
      Directory(dir).createSync();
    }
  }
  File(varsPath).writeAsStringSync(json);
}