import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:git_flux/utils/utils.dart'; Future queryUser(String login) async { var data = await query(''' { user(login: "$login") { name avatarUrl bio email repositories { totalCount } starredRepositories { totalCount } followers { totalCount } following { totalCount } } } '''); return data['user']; } final GlobalKey _refreshIndicatorKey = new GlobalKey(); class UserWidget extends StatefulWidget { final String login; UserWidget(this.login); _UserWidgetState createState() => _UserWidgetState(); } class _UserWidgetState extends State { var user = null; @override void initState() { super.initState(); queryUser(widget.login).then((_user) { setState(() { user = _user; }); }); } @override Widget build(BuildContext context) { return SafeArea( child: RefreshIndicator( key: _refreshIndicatorKey, onRefresh: () async { var _user = await queryUser(widget.login); setState(() { user = _user; }); }, child: Column( children: [ Container( margin: EdgeInsets.symmetric(vertical: 20.0), child: ClipOval( child: Image.network( user['avatarUrl'], fit: BoxFit.fill, width: 64, height: 64, ), ), ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ GestureDetector( child: Column( children: [ Text(user['followers']['totalCount'].toString()), Text('Followers'), ], ), onTap: () { // print(1); }, ), Column( children: [ Text(user['following']['totalCount'].toString()), Text('Following') ], ) ], ), ], ), ), ); } }