Skip to content

Commit

Permalink
[AppRouter] Fix crash on pop page
Browse files Browse the repository at this point in the history
  • Loading branch information
proninyaroslav committed Aug 11, 2024
1 parent 769f68e commit ffe7641
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions lib/ui/app_router.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2021 Yaroslav Pronin <[email protected]>
// Copyright (C) 2021-2024 Yaroslav Pronin <[email protected]>
// Copyright (C) 2021 Insurgo Inc. <[email protected]>
//
// This file is part of LibreTrack.
Expand Down Expand Up @@ -219,7 +219,7 @@ class AppRouterDelegate extends RouterDelegate<AppRoutePath>
reportsRouteUpdateToEngine: true,
pages: pages,
onDidRemovePage: (page) {
_popState();
_stateStack.pop();
},
);
}
Expand Down
34 changes: 19 additions & 15 deletions lib/ui/parcels/parcels_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2021 Yaroslav Pronin <[email protected]>
// Copyright (C) 2021-2024 Yaroslav Pronin <[email protected]>
// Copyright (C) 2021 Insurgo Inc. <[email protected]>
//
// This file is part of LibreTrack.
Expand Down Expand Up @@ -75,11 +75,13 @@ class ParcelsCubit extends Cubit<ParcelsState> {
));

Future<void> observeParcels() async {
emit(ParcelsState.initial(
filters: state.filters,
search: state.search,
sort: state.sort,
));
if (!isClosed) {
emit(ParcelsState.initial(
filters: state.filters,
search: state.search,
sort: state.sort,
));
}

final group = StreamGroup.mergeBroadcast([
_trackRepo.observeAllTracks().asyncMap(
Expand Down Expand Up @@ -119,15 +121,17 @@ class ParcelsCubit extends Cubit<ParcelsState> {
archive.add(info);
}
}
emit(
ParcelsState.loaded(
active: active,
archive: archive,
filters: state.filters,
search: state.search,
sort: state.sort,
),
);
if (!isClosed) {
emit(
ParcelsState.loaded(
active: active,
archive: archive,
filters: state.filters,
search: state.search,
sort: state.sort,
),
);
}
},
failed: (error) {
emit(
Expand Down

0 comments on commit ffe7641

Please sign in to comment.