@@ -4,6 +4,7 @@ import 'package:window_to_front/window_to_front.dart';
4
4
5
5
import 'github_oauth_credentials.dart' ;
6
6
import 'src/github_login.dart' ;
7
+ import 'src/github_summary.dart' ;
7
8
8
9
void main () {
9
10
runApp (const MyApp ());
@@ -35,23 +36,14 @@ class MyHomePage extends StatelessWidget {
35
36
return GithubLoginWidget (
36
37
builder: (context, httpClient) {
37
38
WindowToFront .activate ();
38
- return FutureBuilder <CurrentUser >(
39
- future: viewerDetail (httpClient.credentials.accessToken),
40
- builder: (context, snapshot) {
41
- return Scaffold (
42
- appBar: AppBar (
43
- title: Text (title),
44
- elevation: 2 ,
45
- ),
46
- body: Center (
47
- child: Text (
48
- snapshot.hasData
49
- ? 'Hello ${snapshot .data !.login }!'
50
- : 'Retrieving viewer login details...' ,
51
- ),
52
- ),
53
- );
54
- },
39
+ return Scaffold (
40
+ appBar: AppBar (
41
+ title: Text (title),
42
+ elevation: 2 ,
43
+ ),
44
+ body: GitHubSummary (
45
+ gitHub: _getGitHub (httpClient.credentials.accessToken),
46
+ ),
55
47
);
56
48
},
57
49
githubClientId: githubClientId,
@@ -61,7 +53,6 @@ class MyHomePage extends StatelessWidget {
61
53
}
62
54
}
63
55
64
- Future <CurrentUser > viewerDetail (String accessToken) async {
65
- final gitHub = GitHub (auth: Authentication .withToken (accessToken));
66
- return gitHub.users.getCurrentUser ();
67
- }
56
+ GitHub _getGitHub (String accessToken) {
57
+ return GitHub (auth: Authentication .withToken (accessToken));
58
+ }
0 commit comments