createGist method

Future<Gist> createGist(
  1. Map<String, String> files,
  2. {String? description,
  3. bool public = false}
)

Implementation

Future<Gist> createGist(
  Map<String, String> files, {
  String? description,
  bool public = false,
}) {
  final map = <String, dynamic>{'files': {}};

  if (description != null) {
    map['description'] = description;
  }

  map['public'] = public;

  final f = {};

  for (final key in files.keys) {
    f[key] = {'content': files[key]};
  }

  map['files'] = f;

  return github.postJSON(
    '/gists',
    statusCode: 201,
    body: GitHubJson.encode(map),
    convert: (dynamic i) => Gist.fromJson(i),
  );
}