Skip to content

Commit eddd543

Browse files
committed
Strong mode and some fixes
1 parent ffd3bd6 commit eddd543

12 files changed

+77
-59
lines changed

lib/src/common/activity_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ class EventPoller {
339339

340340
_lastFetched = response.headers['ETag'];
341341

342-
var json = JSON.decode(response.body);
342+
var json = JSON.decode(response.body) as List<Map<String, dynamic>>;
343343

344344
if (!(onlyNew && _timer == null)) {
345345
for (var item in json) {

lib/src/common/authorizations_service.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ class AuthorizationsService extends Service {
1515
/// API docs: https://developer.github.com/v3/oauth_authorizations/#list-your-authorizations
1616
Stream<Authorization> listAuthorizations() {
1717
return new PaginationHelper(_github)
18-
.objects("GET", "/authorizations", Authorization.fromJSON);
18+
.objects("GET", "/authorizations", Authorization.fromJSON)
19+
as Stream<Authorization>;
1920
}
2021

21-
/// Fetches an authorization specified by [name].
22+
/// Fetches an authorization specified by [id].
2223
///
2324
/// API docs: https://developer.github.com/v3/oauth_authorizations/#get-a-single-authorization
2425
Future<Authorization> getAuthorization(int id) {
2526
return _github.getJSON("/authorizations/${id}",
26-
statusCode: 200, convert: Authorization.fromJSON);
27+
statusCode: 200,
28+
convert: Authorization.fromJSON) as Future<Authorization>;
2729
}
2830

2931
// TODO: Implement remaining API methods of authorizations:

lib/src/common/blog_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class BlogService extends Service {
66

77
/// Returns a stream of blog posts for the specified [url].
88
Stream<BlogPost> listPosts([String url = "https://github.com/blog.atom"]) {
9-
var controller = new StreamController();
9+
var controller = new StreamController<BlogPost>();
1010
_github.client.get(url).then((response) {
1111
var document = xml.parse(response.body);
1212

lib/src/common/explore_service.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ExploreService extends Service {
1515
if (since != null)
1616
url += language == null ? "?since=${since}" : "&since=${since}";
1717

18-
var controller = new StreamController();
18+
var controller = new StreamController<TrendingRepository>();
1919

2020
_github.client.get(url).then((response) {
2121
var doc = htmlParser.parse(response.body);
@@ -45,7 +45,7 @@ class ExploreService extends Service {
4545
}
4646

4747
Future<Showcase> getShowcase(ShowcaseInfo info) {
48-
var completer = new Completer();
48+
var completer = new Completer<Showcase>();
4949

5050
_github.client.get(info.url).then((response) {
5151
var doc = htmlParser.parse(response.body);
@@ -60,6 +60,7 @@ class ExploreService extends Service {
6060

6161
var description = page.querySelector(".collection-description");
6262

63+
// TODO: This is most likely wrong
6364
showcase.description = description;
6465
showcase.lastUpdated = lastUpdated;
6566
showcase.title = title;
@@ -89,7 +90,7 @@ class ExploreService extends Service {
8990
}
9091

9192
Stream<ShowcaseInfo> listShowcases() {
92-
var controller = new StreamController();
93+
var controller = new StreamController<ShowcaseInfo>();
9394

9495
Function handleResponse;
9596

lib/src/common/model/activity.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class Event {
2929
event.type = input['type'];
3030

3131
event
32-
..repo = Repository.fromJSON(input['repo'])
33-
..org = Organization.fromJSON(input['org'])
32+
..repo = Repository.fromJSON(input['repo'] as Map<String, dynamic>)
33+
..org = Organization.fromJSON(input['org'] as Map<String, dynamic>)
3434
..createdAt = parseDateTime(input['created_at'])
3535
..id = input['id']
3636
..actor = User.fromJSON(input['actor'])

lib/src/common/model/keys.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class PublicKey {
99
String key;
1010
String title;
1111

12-
static PublicKey fromJSON(input) {
12+
static PublicKey fromJSON(Map<String, dynamic> input) {
1313
if (input == null) return null;
1414

1515
return new PublicKey()
@@ -27,7 +27,7 @@ class CreatePublicKey {
2727
CreatePublicKey(this.title, this.key);
2828

2929
String toJSON() {
30-
var map = {};
30+
var map = <String, dynamic> {};
3131
putValue("title", title, map);
3232
putValue("key", key, map);
3333
return JSON.encode(map);

lib/src/common/model/notifications.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ class Notification {
1414
@ApiName("last_read_at")
1515
DateTime lastReadAt;
1616

17-
static Notification fromJSON(input) {
17+
static Notification fromJSON(Map<String, dynamic> input) {
1818
if (input == null) return null;
1919

2020
return new Notification()
2121
..id = input['id']
22-
..repository = Repository.fromJSON(input['repository'])
23-
..subject = NotificationSubject.fromJSON(input['subject'])
22+
..repository =
23+
Repository.fromJSON(input['repository'] as Map<String, dynamic>)
24+
..subject =
25+
NotificationSubject.fromJSON(input['subject'] as Map<String, dynamic>)
2426
..reason = input['reason']
2527
..unread = input['unread']
2628
..updatedAt = parseDateTime(input['updated_at'])
@@ -33,7 +35,7 @@ class NotificationSubject {
3335
String title;
3436
String type;
3537

36-
static NotificationSubject fromJSON(input) {
38+
static NotificationSubject fromJSON(Map<String, dynamic> input) {
3739
if (input == null) return null;
3840

3941
return new NotificationSubject()

lib/src/common/model/orgs.dart

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Organization {
5555
@ApiName("updated_at")
5656
DateTime updatedAt;
5757

58-
static Organization fromJSON(input) {
58+
static Organization fromJSON(Map<String, dynamic> input) {
5959
if (input == null) return null;
6060

6161
return new Organization()
@@ -82,11 +82,12 @@ class OrganizationMembership {
8282
String state;
8383
Organization organization;
8484

85-
static OrganizationMembership fromJSON(input) {
85+
static OrganizationMembership fromJSON(Map<String, dynamic> input) {
8686
if (input == null) return null;
8787

8888
return new OrganizationMembership()
89-
..organization = Organization.fromJSON(input['organization'])
89+
..organization =
90+
Organization.fromJSON(input['organization'] as Map<String, dynamic>)
9091
..state = input['state'];
9192
}
9293
}
@@ -113,15 +114,16 @@ class Team {
113114
/// Organization
114115
Organization organization;
115116

116-
static Team fromJSON(input) {
117+
static Team fromJSON(Map<String, dynamic> input) {
117118
if (input == null) return null;
118119

119120
return new Team()
120121
..name = input['name']
121122
..id = input['id']
122123
..membersCount = input['members_count']
123124
..reposCount = input['repos_count']
124-
..organization = Organization.fromJSON(input['organization']);
125+
..organization =
126+
Organization.fromJSON(input['organization'] as Map<String, dynamic>);
125127
}
126128
}
127129

@@ -159,7 +161,7 @@ class TeamMember {
159161
@ApiName("html_url")
160162
String htmlUrl;
161163

162-
static TeamMember fromJSON(input) {
164+
static TeamMember fromJSON(Map<String, dynamic> input) {
163165
if (input == null) return null;
164166

165167
var member = new TeamMember();
@@ -178,7 +180,7 @@ class TeamRepository extends Repository {
178180
/// Repository Permissions.
179181
TeamRepositoryPermissions permissions;
180182

181-
static TeamRepository fromJSON(input) {
183+
static TeamRepository fromJSON(Map<String, dynamic> input) {
182184
if (input == null) return null;
183185

184186
return new TeamRepository()
@@ -204,9 +206,10 @@ class TeamRepository extends Repository {
204206
..forksCount = input['forks_count']
205207
..createdAt = parseDateTime(input['created_at'])
206208
..pushedAt = parseDateTime(input['pushed_at'])
207-
..owner = UserInformation.fromJSON(input['owner'])
209+
..owner = UserInformation.fromJSON(input['owner'] as Map<String, dynamic>)
208210
..isPrivate = input['private']
209-
..permissions = TeamRepositoryPermissions.fromJSON(input['permissions']);
211+
..permissions = TeamRepositoryPermissions
212+
.fromJSON(input['permissions'] as Map<String, dynamic>);
210213
}
211214
}
212215

@@ -221,7 +224,7 @@ class TeamRepositoryPermissions {
221224
/// Pull Access
222225
bool pull;
223226

224-
static TeamRepositoryPermissions fromJSON(input) {
227+
static TeamRepositoryPermissions fromJSON(Map<String, dynamic> input) {
225228
if (input == null) return null;
226229

227230
return new TeamRepositoryPermissions()

lib/src/common/model/pulls.dart

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@ class PullRequestInformation {
5656

5757
PullRequestInformation([this.isCompletePullRequest = false]);
5858

59-
static PullRequestInformation fromJSON(input, [PullRequestInformation into]) {
59+
static PullRequestInformation fromJSON(Map<String, dynamic> input,
60+
[PullRequestInformation into]) {
6061
if (input == null) return null;
6162

6263
var pr = into != null ? into : new PullRequestInformation();
63-
pr.head = PullRequestHead.fromJSON(input['head']);
64-
pr.base = PullRequestHead.fromJSON(input['base']);
64+
pr.head = PullRequestHead.fromJSON(input['head'] as Map<String, dynamic>);
65+
pr.base = PullRequestHead.fromJSON(input['base'] as Map<String, dynamic>);
6566
pr.htmlUrl = input['html_url'];
6667
pr.diffUrl = input['diff_url'];
6768
pr.patchUrl = input['patch_url'];
@@ -113,7 +114,7 @@ class PullRequest extends PullRequestInformation {
113114

114115
PullRequest() : super(true);
115116

116-
static PullRequest fromJSON(input) {
117+
static PullRequest fromJSON(Map<String, dynamic> input) {
117118
if (input == null) return null;
118119

119120
PullRequest pr = PullRequestInformation.fromJSON(input, new PullRequest());
@@ -139,7 +140,7 @@ class PullRequestMerge {
139140

140141
PullRequestMerge();
141142

142-
static PullRequestMerge fromJSON(input) {
143+
static PullRequestMerge fromJSON(Map<String, dynamic> input) {
143144
if (input == null) return null;
144145

145146
return new PullRequestMerge()
@@ -166,15 +167,15 @@ class PullRequestHead {
166167
/// Repository
167168
Repository repo;
168169

169-
static PullRequestHead fromJSON(input) {
170+
static PullRequestHead fromJSON(Map<String, dynamic> input) {
170171
if (input == null) return null;
171172

172173
var head = new PullRequestHead();
173174
head.label = input['label'];
174175
head.ref = input['ref'];
175176
head.sha = input['sha'];
176177
head.user = User.fromJSON(input['user']);
177-
head.repo = Repository.fromJSON(input['repo']);
178+
head.repo = Repository.fromJSON(input['repo'] as Map<String, dynamic>);
178179
return head;
179180
}
180181
}
@@ -196,7 +197,7 @@ class CreatePullRequest {
196197
CreatePullRequest(this.title, this.head, this.base, {this.body});
197198

198199
String toJSON() {
199-
var map = {};
200+
var map = <String, dynamic>{};
200201
putValue("title", title, map);
201202
putValue("head", head, map);
202203
putValue("base", base, map);
@@ -240,7 +241,7 @@ class PullRequestComment {
240241
@ApiName("_links")
241242
Links links;
242243

243-
static PullRequestComment fromJSON(input) {
244+
static PullRequestComment fromJSON(Map<String, dynamic> input) {
244245
if (input == null) return null;
245246

246247
return new PullRequestComment()
@@ -275,7 +276,7 @@ class CreatePullRequestComment {
275276
CreatePullRequestComment(this.body, this.commitId, this.path, this.position);
276277

277278
String toJSON() {
278-
var map = {};
279+
var map = <String, dynamic>{};
279280
putValue("body", body, map);
280281
putValue("commit_id", commitId, map);
281282
putValue("path", path, map);
@@ -298,7 +299,7 @@ class PullRequestFile {
298299
String rawUrl;
299300
String patch;
300301

301-
static PullRequestFile fromJSON(input) {
302+
static PullRequestFile fromJSON(Map<String, dynamic> input) {
302303
var file = new PullRequestFile();
303304
file.sha = input['sha'];
304305
file.filename = input['filename'];

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