TL;DR - 그냥 pushNamed를 쓰자

플러터에서 라우팅할 때 Navigator를 많이 씁니다. 스택이 있고, 그 위에 위젯을 쌓아 나가는 방식인데요, 푸시할 때 push와 pushNamed 두 메소드를 쓸 수 있습니다.

뭘 써야 더 좋을까 찾아봤는데 작은 규모 프로젝트면 push를 써도 상관 없는데, 프로젝트 사이즈가 커지고 라우팅 경로가 복잡해지면 중복되는 코드 양이 많아지니 pushNamed()를 사용하라고 합니다.

 

Document the pros and cons of using push vs pushNamed · Issue #3867 · flutter/flutter

Right now I’m only using Navigator.push(context, new MaterialPageRoute(... I know there are some other options like the routes named parameter to MaterialApp constructor. What are the pros/cons to ...

github.com

플러터 이슈에서 해당 내용에 대해 논하기도 했네요

반응형