44 lines
1.0 KiB
Dart
44 lines
1.0 KiB
Dart
import 'dart:developer';
|
|
|
|
import 'package:didvan/models/enums.dart';
|
|
import 'package:didvan/models/new_statistic/new_statistics_model.dart';
|
|
import 'package:didvan/providers/core.dart';
|
|
import 'package:didvan/services/network/request.dart';
|
|
import 'package:didvan/services/network/request_helper.dart';
|
|
|
|
class NewStatisticState extends CoreProvier {
|
|
final List<CategoryList> contents = [];
|
|
|
|
Future<void> getStatistic() async {
|
|
appState = AppState.busy;
|
|
final RequestService service = RequestService(
|
|
RequestHelper.newStatisticOverViw(),
|
|
);
|
|
await service.httpGet();
|
|
if (service.isSuccess) {
|
|
final res = NewStatisticModel.fromJson(service.result);
|
|
|
|
for (var element in res.lists) {
|
|
contents.add(element);
|
|
}
|
|
|
|
appState = AppState.idle;
|
|
return;
|
|
}
|
|
appState = AppState.failed;
|
|
}
|
|
|
|
void init() {
|
|
Future.delayed(Duration.zero, () {
|
|
getStatistic();
|
|
});
|
|
}
|
|
|
|
void resetState() {
|
|
contents.clear();
|
|
notifyListeners();
|
|
getStatistic();
|
|
log("Blakh");
|
|
}
|
|
}
|