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주차 과제 #2

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

Conversation

hururu1234
Copy link

Description

getx의 router기능을 사용했습니다. 알려주신 방향이랑 다른데 일단 비스무리하게 구동하게 만들었습니다..
일주일 안에 날씨 데이터가지고 router기능 구현하는데 자신이 없어서 getx사용했습니다...
시험이 임박해서 지난 주 피드백 수정 못했습니다....

Important content

Question

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 자체적인 라우팅 기능을 사용하는 것도 충분히 좋다고 생각합니다!

import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';

class SecondPage 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.

폴더 구조를 파악하기 쉽게 클래스 이름과 같은 파일명을 사용하는 게 좋을 것 같습니다.

theme: ThemeData(fontFamily: 'NotoSnas'),
debugShowCheckedModeBanner: false,
initialRoute: '/splash',
getPages: [
Copy link
Collaborator

Choose a reason for hiding this comment

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

getX의 라우팅을 사용하셨네요. 물론 상태관리도 할 수 있으면서 라우팅 기능도 있고, 직관적으로 사용하기 쉬워서 사용하신 것 같은데, 알려드린 ShellRoute의 기능을 사용하면 쉽게 중첩된 라우팅을 할 수 있도록 지원해줍니다.

onTap: (index) {
if (index == 0) {
// Named Router를 사용하여 '/weatherscreen' 페이지로 이동
Get.toNamed('/splash');
Copy link
Collaborator

Choose a reason for hiding this comment

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

주석과 다른 페이지로 라우팅하는 것 같습니다. 수정이 필요해보입니다.

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와 바닐라 코드가 섞여 있는 부분만 조금 수정하면 될 것 같습니다.
이미 언급했듯이 Navigator 1.0과 GetX의 라우팅은 방식 자체가 다르니까 주의하세요.


제가 잘못된 정보를 알고 있었네요.
GetMaterialApp을 통한 라우팅은 Navigator 1.0을 기반으로 하지만 context를 사용하지 않기 때문에 조금 다릅니다.
반면 GetMaterialApp.router를 통한 라우팅은 Navigator 2.0을 기반으로 합니다.

Comment on lines +38 to +46
if (refreshToken == null || accessToken == null) {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (_) => const LoginScreen()),
(route) => false);
} else {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (_) => const Loading()), (route) => false);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

해당 코드는 플러터의 기본 기능인 Navigator 1.0을 사용한 코드로 보입니다.
Navigator 1.0은 스택을 기반으로 동작하고 이후에 나온 Navigator 2.0, 그리고 Navigator 2.0 API를 기반으로 만들어진 go_router 혹은 GetX는 모두 Page 객체 등을 기반으로 동작합니다. 이미 GetX의 라우팅 기능을 사용하려고 했으니 굳이 Navigator 1.0을 사용하지 않아도 될 것 같습니다.

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