Skip to content

Commit 51b7989

Browse files
committed
Fix Strong mode, other fixes
1 parent a76ffe1 commit 51b7989

File tree

3 files changed

+79
-48
lines changed

3 files changed

+79
-48
lines changed

lib/src/common/issues_service.dart

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class IssuesService extends Service {
8989
if (milestoneNumber != null) {
9090
// should be a milestone number (e.g. '34') not a milestone title
9191
// (e.g. '1.15')
92-
params['milestone'] = milestoneNumber;
92+
params['milestone'] = milestoneNumber.toString();
9393
}
9494

9595
if (state != null) {
@@ -118,7 +118,8 @@ class IssuesService extends Service {
118118
}
119119

120120
return new PaginationHelper(_github)
121-
.objects("GET", pathSegment, Issue.fromJSON, params: params);
121+
.objects("GET", pathSegment, Issue.fromJSON, params: params)
122+
as Stream<Issue>;
122123
}
123124

124125
/// Edit an issue.
@@ -129,7 +130,8 @@ class IssuesService extends Service {
129130
.request("PATCH", '/repos/${slug.fullName}/issues/${issueNumber}',
130131
body: issue.toJSON())
131132
.then((response) {
132-
return Issue.fromJSON(JSON.decode(response.body));
133+
return Issue.fromJSON(JSON.decode(response.body) as Map<String, dynamic>)
134+
as Future<Issue>;
133135
});
134136
}
135137

@@ -138,7 +140,7 @@ class IssuesService extends Service {
138140
/// API docs: https://developer.github.com/v3/issues/#get-a-single-issue
139141
Future<Issue> get(RepositorySlug slug, int issueNumber) {
140142
return _github.getJSON("/repos/${slug.fullName}/issues/${issueNumber}",
141-
convert: Issue.fromJSON);
143+
convert: Issue.fromJSON) as Future<Issue>;
142144
}
143145

144146
/// Create an issue.
@@ -154,7 +156,8 @@ class IssuesService extends Service {
154156
throw new GitHubError(_github, response.body);
155157
}
156158

157-
return Issue.fromJSON(JSON.decode(response.body));
159+
return Issue.fromJSON(JSON.decode(response.body) as Map<String, dynamic>)
160+
as Future<Issue>;
158161
}
159162

160163
/// Lists all available assignees (owners and collaborators) to which issues
@@ -163,7 +166,8 @@ class IssuesService extends Service {
163166
/// API docs: https://developer.github.com/v3/issues/assignees/#list-assignees
164167
Stream<User> listAssignees(RepositorySlug slug) {
165168
return new PaginationHelper(_github)
166-
.objects("GET", "/repos/${slug.fullName}/assignees", User.fromJSON);
169+
.objects("GET", "/repos/${slug.fullName}/assignees", User.fromJSON)
170+
as Stream<User>;
167171
}
168172

169173
/// Checks if a user is an assignee for the specified repository.
@@ -183,23 +187,25 @@ class IssuesService extends Service {
183187
return new PaginationHelper(_github).objects(
184188
'GET',
185189
'/repos/${slug.fullName}/issues/${issueNumber}/comments',
186-
IssueComment.fromJSON);
190+
IssueComment.fromJSON) as Stream<IssueComment>;
187191
}
188192

189193
/// Lists all comments in a repository.
190194
///
191195
/// API docs: https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
192196
Stream<IssueComment> listCommentsByRepo(RepositorySlug slug) {
193-
return new PaginationHelper(_github).objects('GET',
194-
'/repos/${slug.fullName}/issues/comments', IssueComment.fromJSON);
197+
return new PaginationHelper(_github).objects(
198+
'GET',
199+
'/repos/${slug.fullName}/issues/comments',
200+
IssueComment.fromJSON) as Stream<IssueComment>;
195201
}
196202

197203
/// Fetches the specified issue comment.
198204
///
199205
/// API docs: https://developer.github.com/v3/issues/comments/#get-a-single-comment
200206
Future<IssueComment> getComment(RepositorySlug slug, int id) {
201207
return _github.getJSON("/repos/${slug.fullName}/issues/comments/${id}",
202-
convert: IssueComment.fromJSON);
208+
convert: IssueComment.fromJSON) as Future<IssueComment>;
203209
}
204210

205211
/// Creates a new comment on the specified issue
@@ -212,7 +218,7 @@ class IssuesService extends Service {
212218
'/repos/${slug.fullName}/issues/${issueNumber}/comments',
213219
body: it,
214220
convert: IssueComment.fromJSON,
215-
statusCode: StatusCodes.CREATED);
221+
statusCode: StatusCodes.CREATED) as Future<IssueComment>;
216222
}
217223

218224
// TODO: Implement editComment: https://developer.github.com/v3/issues/comments/#edit-a-comment
@@ -232,16 +238,18 @@ class IssuesService extends Service {
232238
///
233239
/// API docs: https://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository
234240
Stream<IssueLabel> listLabels(RepositorySlug slug) {
235-
return new PaginationHelper(_github)
236-
.objects("GET", "/repos/${slug.fullName}/labels", IssueLabel.fromJSON);
241+
return new PaginationHelper(_github).objects(
242+
"GET", "/repos/${slug.fullName}/labels", IssueLabel.fromJSON)
243+
as Stream<IssueLabel>;
237244
}
238245

239246
/// Fetches a single label.
240247
///
241248
/// API docs: https://developer.github.com/v3/issues/labels/#get-a-single-label
242249
Future<IssueLabel> getLabel(RepositorySlug slug, String name) {
243250
return _github.getJSON("/repos/${slug.fullName}/labels/${name}",
244-
convert: IssueLabel.fromJSON, statusCode: StatusCodes.OK);
251+
convert: IssueLabel.fromJSON,
252+
statusCode: StatusCodes.OK) as Future<IssueLabel>;
245253
}
246254

247255
/// Creates a new label on the specified repository.
@@ -251,7 +259,7 @@ class IssuesService extends Service {
251259
RepositorySlug slug, String name, String color) {
252260
return _github.postJSON("/repos/${slug.fullName}/labels",
253261
body: JSON.encode({"name": name, "color": color}),
254-
convert: IssueLabel.fromJSON);
262+
convert: IssueLabel.fromJSON) as Future<IssueLabel>;
255263
}
256264

257265
/// Edits a label.
@@ -260,7 +268,7 @@ class IssuesService extends Service {
260268
Future<IssueLabel> editLabel(RepositorySlug slug, String name, String color) {
261269
return _github.postJSON("/repos/${slug.fullName}/labels/${name}",
262270
body: JSON.encode({"name": name, "color": color}),
263-
convert: IssueLabel.fromJSON);
271+
convert: IssueLabel.fromJSON) as Future<IssueLabel>;
264272
}
265273

266274
/// Deletes a label.
@@ -280,7 +288,7 @@ class IssuesService extends Service {
280288
return new PaginationHelper(_github).objects(
281289
"GET",
282290
"/repos/${slug.fullName}/issues/${issueNumber}/labels",
283-
IssueLabel.fromJSON);
291+
IssueLabel.fromJSON) as Stream<IssueLabel>;
284292
}
285293

286294
/// Adds labels to an issue.
@@ -289,9 +297,11 @@ class IssuesService extends Service {
289297
Future<List<IssueLabel>> addLabelsToIssue(
290298
RepositorySlug slug, int issueNumber, List<String> labels) {
291299
return _github.postJSON(
292-
"/repos/${slug.fullName}/issues/${issueNumber}/labels",
293-
body: JSON.encode(labels),
294-
convert: (input) => input.map((it) => IssueLabel.fromJSON(it)));
300+
"/repos/${slug.fullName}/issues/${issueNumber}/labels",
301+
body: JSON.encode(labels),
302+
convert: (input) =>
303+
input.map((Map<String, dynamic> it) => IssueLabel.fromJSON(it)))
304+
as Future<List<IssueLabel>>;
295305
}
296306

297307
/// Replaces all labels for an issue.
@@ -303,7 +313,9 @@ class IssuesService extends Service {
303313
.request("PUT", "/repos/${slug.fullName}/issues/${issueNumber}/labels",
304314
body: JSON.encode(labels))
305315
.then((response) {
306-
return JSON.decode(response.body).map((it) => IssueLabel.fromJSON(it));
316+
return JSON
317+
.decode(response.body)
318+
.map((Map<String, dynamic> it) => IssueLabel.fromJSON(it));
307319
});
308320
}
309321

@@ -335,7 +347,8 @@ class IssuesService extends Service {
335347
/// API docs: https://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository
336348
Stream<Milestone> listMilestones(RepositorySlug slug) {
337349
return new PaginationHelper(_github).objects(
338-
"GET", "/repos/${slug.fullName}/milestones", Milestone.fromJSON);
350+
"GET", "/repos/${slug.fullName}/milestones", Milestone.fromJSON)
351+
as Stream<Milestone>;
339352
}
340353

341354
// TODO: Implement getMilestone: https://developer.github.com/v3/issues/milestones/#get-a-single-milestone
@@ -346,7 +359,8 @@ class IssuesService extends Service {
346359
Future<Milestone> createMilestone(
347360
RepositorySlug slug, CreateMilestone request) {
348361
return _github.postJSON("/repos/${slug.fullName}/milestones",
349-
body: JSON.encode(request.toJSON()), convert: Milestone.fromJSON);
362+
body: JSON.encode(request.toJSON()),
363+
convert: Milestone.fromJSON) as Future<Milestone>;
350364
}
351365

352366
// TODO: Implement editMilestone: https://developer.github.com/v3/issues/milestones/#update-a-milestone

lib/src/common/misc_service.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ class MiscService extends Service {
1212
///
1313
/// API docs: https://developer.github.com/v3/emojis/
1414
Future<Map<String, String>> listEmojis() {
15-
return _github.getJSON("/emojis", statusCode: StatusCodes.OK);
15+
return _github.getJSON("/emojis", statusCode: StatusCodes.OK)
16+
as Future<Map<String, String>>;
1617
}
1718

1819
/// Lists available .gitignore template names.
1920
///
2021
/// API docs: https://developer.github.com/v3/gitignore/#listing-available-templates
2122
Future<List<String>> listGitignoreTemplates() {
22-
return _github.getJSON("/gitignore/templates");
23+
return _github.getJSON("/gitignore/templates") as Future<List<String>>;
2324
}
2425

2526
/// Gets a .gitignore template by [name].
@@ -28,7 +29,7 @@ class MiscService extends Service {
2829
/// API docs: https://developer.github.com/v3/gitignore/#get-a-single-template
2930
Future<GitignoreTemplate> getGitignoreTemplate(String name) {
3031
return _github.getJSON("/gitignore/templates/${name}",
31-
convert: GitignoreTemplate.fromJSON);
32+
convert: GitignoreTemplate.fromJSON) as Future<GitignoreTemplate>;
3233
}
3334

3435
/// Renders Markdown from the [input].
@@ -64,14 +65,15 @@ class MiscService extends Service {
6465
/// Gets the GitHub API Status.
6566
Future<APIStatus> getApiStatus() {
6667
return _github.getJSON("https://status.github.com/api/status.json",
67-
statusCode: StatusCodes.OK, convert: APIStatus.fromJSON);
68+
statusCode: StatusCodes.OK,
69+
convert: APIStatus.fromJSON) as Future<APIStatus>;
6870
}
6971

7072
/// Returns a stream of Octocats from Octodex.
7173
///
7274
/// See: https://octodex.github.com/
7375
Stream<Octocat> listOctodex({bool cors: false}) {
74-
var controller = new StreamController();
76+
var controller = new StreamController<Octocat>();
7577

7678
var u = "http://feeds.feedburner.com/Octocats.xml";
7779

@@ -102,7 +104,7 @@ class MiscService extends Service {
102104

103105
/// Returns an ASCII Octocat with the specified [text].
104106
Future<String> getOctocat([String text]) {
105-
var params = {};
107+
var params = <String, String>{};
106108

107109
if (text != null) {
108110
params["s"] = text;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy