updateData method

Future<void> updateData()

updates data to actual

Implementation

Future<void> updateData() async {
  if (_isInit == false) throw "You should call unit() before";

  if (_token == null) throw "You should call login() before";

  var user = await _vkApi.method('account.getProfileInfo');

  if (user == null) {
    _profile = null;
    _token = null;
    return notifyListeners();
  }

  var photosInfo = await _vkApi.method('users.get',
      params: {'fields': 'photo_50,photo_100,photo_200,photo_max_orig', 'user_ids': '${user['id']}'});
  _profile = VkUser.fromJSON(user, photosInfo[0]);
  notifyListeners();
}