Update new statistic and stats general state; clear old content before adding new
In `new_statistic.dart`, updated the onTap function for a GestureDetector to clear old content before adding new content to the list. In `new_statistics_state.dart`, added a line to clear the contents list before adding new content to it. In `stat_cats_general_state.dart`, added a few lines to clear the contents list before adding new content to it.
This commit is contained in:
parent
6740479395
commit
7ecf074bb8
|
|
@ -70,11 +70,11 @@ class _NewStatisticState extends State<NewStatistic> {
|
||||||
),
|
),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => Future.delayed(Duration.zero, () {
|
onTap: () => Future.delayed(Duration.zero, () {
|
||||||
Navigator.of(context).pushNamed(Routes.statGeneral,
|
Navigator.of(context)
|
||||||
arguments: {
|
.pushNamed(Routes.statGeneral, arguments: {
|
||||||
"id": 7,
|
"id": 7,
|
||||||
"title": state.contents[0].header
|
"title": state.contents[0].header,
|
||||||
});
|
}).then((value) => state.getStatistic());
|
||||||
}),
|
}),
|
||||||
child: StatHeader(header: state.contents[0].header)),
|
child: StatHeader(header: state.contents[0].header)),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ class NewStatisticState extends CoreProvier {
|
||||||
if (service.isSuccess) {
|
if (service.isSuccess) {
|
||||||
final res = NewStatisticModel.fromJson(service.result);
|
final res = NewStatisticModel.fromJson(service.result);
|
||||||
|
|
||||||
|
contents.clear();
|
||||||
|
|
||||||
for (var element in res.lists) {
|
for (var element in res.lists) {
|
||||||
contents.add(element);
|
contents.add(element);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
import 'package:didvan/models/enums.dart';
|
import 'package:didvan/models/enums.dart';
|
||||||
import 'package:didvan/models/new_statistic/general_item_model.dart';
|
import 'package:didvan/models/new_statistic/general_item_model.dart';
|
||||||
import 'package:didvan/models/requests/newstats_general.dart';
|
import 'package:didvan/models/requests/newstats_general.dart';
|
||||||
|
|
@ -40,6 +39,9 @@ class StatGeneralScreenState extends CoreProvier {
|
||||||
await service.httpGet();
|
await service.httpGet();
|
||||||
if (service.isSuccess) {
|
if (service.isSuccess) {
|
||||||
final content = StatisticGeneralContent.fromJson(service.result);
|
final content = StatisticGeneralContent.fromJson(service.result);
|
||||||
|
|
||||||
|
contents.clear();
|
||||||
|
|
||||||
contents.addAll(content.contents);
|
contents.addAll(content.contents);
|
||||||
|
|
||||||
appState = AppState.idle;
|
appState = AppState.idle;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue