completed velocity integration
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:qpay/http/http.dart';
|
||||
import 'package:qpay/models/api_response.dart';
|
||||
import 'package:qpay/models/pageable_model.dart';
|
||||
|
||||
class HistoryModel {
|
||||
@@ -17,17 +18,7 @@ class HistoryController extends ChangeNotifier {
|
||||
|
||||
HistoryController(this.context);
|
||||
|
||||
void _showErrorSnackBar(String? message) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message.toString()),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
backgroundColor: Colors.deepOrange,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getTransactions(Map<String, String> params) async {
|
||||
Future<ApiResponse<List<Map<String, dynamic>>>> getTransactions(Map<String, String> params) async {
|
||||
model.isLoading = true;
|
||||
if (params['page'] == '0') {
|
||||
model.transactions = getFakeTransactions();
|
||||
@@ -51,16 +42,19 @@ class HistoryController extends ChangeNotifier {
|
||||
model.pageableModel!.content
|
||||
.map((e) => e as Map<String, dynamic>)
|
||||
.toList();
|
||||
} catch (e) {
|
||||
logger.e(e);
|
||||
_showErrorSnackBar(
|
||||
"Problem fetching transactions, are you connected to the internet?",
|
||||
);
|
||||
model.errorMessage = e.toString();
|
||||
model.transactions = [];
|
||||
} finally {
|
||||
|
||||
model.isLoading = false;
|
||||
notifyListeners();
|
||||
return ApiResponse.success(List<Map<String, dynamic>>.from(model.transactions));
|
||||
} catch (e) {
|
||||
logger.e(e);
|
||||
model.errorMessage = e.toString();
|
||||
model.transactions = [];
|
||||
model.isLoading = false;
|
||||
notifyListeners();
|
||||
return ApiResponse.failure(
|
||||
"Problem fetching transactions, are you connected to the internet?",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user