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(
|
||||
onTap: () => Future.delayed(Duration.zero, () {
|
||||
Navigator.of(context).pushNamed(Routes.statGeneral,
|
||||
arguments: {
|
||||
Navigator.of(context)
|
||||
.pushNamed(Routes.statGeneral, arguments: {
|
||||
"id": 7,
|
||||
"title": state.contents[0].header
|
||||
});
|
||||
"title": state.contents[0].header,
|
||||
}).then((value) => state.getStatistic());
|
||||
}),
|
||||
child: StatHeader(header: state.contents[0].header)),
|
||||
SizedBox(
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ class NewStatisticState extends CoreProvier {
|
|||
if (service.isSuccess) {
|
||||
final res = NewStatisticModel.fromJson(service.result);
|
||||
|
||||
contents.clear();
|
||||
|
||||
for (var element in res.lists) {
|
||||
contents.add(element);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import 'package:didvan/models/enums.dart';
|
||||
import 'package:didvan/models/new_statistic/general_item_model.dart';
|
||||
import 'package:didvan/models/requests/newstats_general.dart';
|
||||
|
|
@ -40,6 +39,9 @@ class StatGeneralScreenState extends CoreProvier {
|
|||
await service.httpGet();
|
||||
if (service.isSuccess) {
|
||||
final content = StatisticGeneralContent.fromJson(service.result);
|
||||
|
||||
contents.clear();
|
||||
|
||||
contents.addAll(content.contents);
|
||||
|
||||
appState = AppState.idle;
|
||||
|
|
|
|||
Loading…
Reference in New Issue