Skip to content

Commit 7d910dc

Browse files
author
Miqueas
committed
Updated Dart example
1 parent adaedaf commit 7d910dc

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

Github.dart

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'package:args/args.dart';
2+
import 'package:dio/dio.dart';
13
import 'dart:convert';
24
import 'dart:io';
35

@@ -23,11 +25,23 @@ class GthUser {
2325

2426
GthUser(String username) : this._url = BASE_URL + username;
2527

26-
void init() async {}
28+
Future<void> init() async {
29+
var obj = await Dio().get(this._url).data;
30+
31+
this.name = obj["name"];
32+
this.bio = obj["bio"];
33+
this.link = obj["html_url"];
34+
35+
this.repos = GthUserItem(obj["public_repos"]);
36+
this.gists = GthUserItem(obj["public_gists"]);
37+
this.followers = GthUserItem(obj["followers"]);
38+
this.following = GthUserItem(obj["following"]);
39+
}
40+
41+
Future<void> fetch(String thing) async {}
2742
}
2843

2944
void main(List<String> args) async {
3045
var user = GthUser(args[0]);
31-
user.init();
32-
print(user._url);
46+
await user.init();
3347
}

0 commit comments

Comments
 (0)