merge method Null safety

Future<PullRequestMerge> merge(
  1. RepositorySlug slug,
  2. int number,
  3. {String? message}
)

Merge a pull request (Merge Button).

API docs: https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button

Implementation

Future<PullRequestMerge> merge(
  RepositorySlug slug,
  int number, {
  String? message,
}) {
  final json = <String, dynamic>{};

  if (message != null) {
    json['commit_message'] = message;
  }

  return github
      .request('PUT', '/repos/${slug.fullName}/pulls/$number/merge',
          body: GitHubJson.encode(json))
      .then((response) {
    return PullRequestMerge.fromJson(
        jsonDecode(response.body) as Map<String, dynamic>);
  });
}