pushAndRemoveUntil and pushReplacement are two navigation methods in Flutter's Navigator widget.
pushAndRemoveUntil pushes a new route onto the navigator stack and removes all the routes below it until a specified route is encountered. It takes two arguments:
- The context in which the Navigator is mounted.
- A RoutePredicate specifies the route that should stop the removal process
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => NewRoute()),
);
pushReplacement pushes a new route onto the navigator stack and removes the current route from the stack.
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (context) => NewRoute()),
ModalRoute.withName('/'),
);
In short, pushReplacement only removes the current route, whereas pushAndRemoveUntil removes all the routes below it until a specified route is encountered.
'[Flutter + Dart]' 카테고리의 다른 글
[Flutter] 사진 업로드시 필요한 비동기처리, Future.wait(), GCS 이미지 업로드, 동시성 프로그래밍, 병렬처리 등 (0) | 2023.04.01 |
---|---|
[Git] 다른 브랜치에 머지된 커밋 취소하기 revoke하는 방법 (0) | 2023.01.28 |
[Flutter] 오류 대잔치 플러터 error build: Command PhaseScriptExecution failed with a nonzero exit code (0) | 2023.01.10 |
[Flutter] M1/M2 Silicon Mac Cocoapod관련 오류 해결법 (0) | 2023.01.08 |
[Flutter] M2 BUILD FAILED (macOS 12.6 using ruby-build 20221225) (1) | 2023.01.08 |