import 'dart:async'; import 'dart:convert'; import 'dart:io'; import 'package:unit2/model/login_data/version_info.dart'; import 'package:http/http.dart' as http; import '../../utils/text_container.dart'; import '../../utils/urls.dart'; class AuthService { static final AuthService _instance = AuthService(); static AuthService get instance => _instance; Future getVersionInfo() async { VersionInfo versionInfo = VersionInfo(); Map headers = { 'Content-Type': 'application/json; charset=UTF-8', HttpHeaders.authorizationHeader: 'UniT2', 'X-User': "" }; try { http.Response response = await http.get( Uri.https('unitylb1.agusandelnorte.gov.ph', '/unit2/api/sys/apk_version/latest/'), headers: headers); if (response.statusCode == 200) { Map data = jsonDecode(response.body); versionInfo = VersionInfo.fromJson(data['data']); } } on TimeoutException catch (e) { throw (timeoutError); } on SocketException catch (e) { throw (timeoutError); } catch (e) { throw (e.toString()); } return versionInfo; } }