Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'8주차' #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

'8주차' #4

wants to merge 1 commit into from

Conversation

KOLPARK
Copy link

@KOLPARK KOLPARK commented Dec 3, 2023

Description

  • firstpage,secondpage,thirdpage로 총 페이지 3개를 만들어서 firstpage에는 날씨정보를 받아오고, secondpage에는 저장한 날씨를 보여주는 페이지로 만들었습니다.
  • 또한 라우터로 페이지들을 움직일 수 있도록 구현하였습니다.

Important content

  • 기존에 작업했던 날씨코드에 추가로 라우터를 넣어서 작업하려고 하였지만 파일이 많이 충돌하여 새롭게 만들었습니다.
  • 내 위치를 받아와 그 위치에 맞게 날씨를 보여주도록 하다가 급한대로 지역을 정해서 화면에만나오도록 만들었습니다.
  • 이번주가 바빠서 아직 라우터에 대해 이해하지 못한부분이 많아 급하게 작업하느라 오류와 하고싶은것들을 너무 못넣었네요... 죄송합니다...

Question

  • getx를 사용하여 라우터를 관리해보고 싶습니다.

Reference

깃허브 및 구글링

Copy link
Collaborator

@labyrinth30 labyrinth30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이번주는 라우팅을 가르쳐드린 주였으니 라우팅쪽만 코멘트 달았습니다. 제가 생각했을 때 고라우터의 장점은 쉘 라우팅을 통한 중첩 라우팅의 쉬운 구현과 리다이렉션이라는 강력한 기능을 사용할 수 있는 것이라고 생각해요. 추후 프로젝트 때 잘 사용하셨으면 좋겠습니다. 고생했습니다. getX의 라우팅 기능도 사용할 순 있지만(충분히 간단합니다), getX는 다목적 라이브러리고 GoRouter는 라우팅만을 위한 라이브러리다보니 상태관리를 위해 Provider같은 타 라이브러리를 사용했을 때에도 같이 사용할 수 있다는 장점이 있어 더욱 추천드리는 바입니다.

}

// NavBarWidget
class NavBarWidget extends StatelessWidget {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

딱 제가 생각한 방식으로 구현하셨네요. 이 방식이 쉘 라우트를 사용할 때 상당히 유용하다고 생각해서 과제로 드렸습니다.

void _onItemTapped(int index, BuildContext context) {
switch (index) {
case 0:
GoRouter.of(context).go('/First');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분이 길다고 느껴지시다면 context.go('/First') 로 단축하여 사용도 가능합니다.

Copy link
Collaborator

@cucumber99 cucumber99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

라우팅은 문제없이 잘 되는 것 같네요.
GetX나 go_router 모두 Navigator 2.0 API를 기반으로 만들어진 라이브러리입니다.
물론 GetX는 라우팅 이외에 상태 관리나 종속성 주입 등의 기능을 모두 포함하고 있죠.
하지만 GetX는 편리함과 동시에 보이지 않는 오류가 발생할 가능성이 높습니다.
그래서 요새는 잘 안쓰이는 추세에요.
GetX를 통한 라우팅은 최상위 위젯을 GetMaterialApp으로 감싸면 되니 간단하긴 합니다.
본인이 사용하고 싶은 것을 사용하면 되겠습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants