todaysTransactionsService function
Future<Map<String, dynamic>>
todaysTransactionsService(- BuildContext context
)
Implementation
Future<Map<String, dynamic>> todaysTransactionsService(
BuildContext context,
) async {
final bool internetStatus = await checkInternetConnection();
if (!internetStatus) {
Transitions(
context: context,
child: const NoInternetPage(),
removeUntil: true,
);
return <String, dynamic>{
'no_network': internetStatus,
};
}
final Box<MyAccountModel> userBox = Hive.box('user');
final http.Response response = await http.get(
Uri.parse(
'${ServicesEnvironment.protocol}${ServicesEnvironment.authority}${ServicesEnvironment.unencodedPath}$endPoint',
),
headers: <String, String>{
'Content-Type': 'application/json; charset=utf-8',
'Authorization': 'Bearer ${userBox.get('user')?.token}',
},
);
Map<String, dynamic> decodedResponse;
try {
decodedResponse = json.decode(response.body);
} catch (exception) {
return Future.error(GlobalMessagesEnvironment.genericError);
}
return decodedResponse;
}