인프런 커뮤니티 질문&답변

Gavin님의 프로필 이미지

작성한 질문수

GetX 기반 Flutter 앱 만들기

홈 화면 만들기

PageTransition 적용 후 뷰 적용 되지 않는 문제가 있습니다.

해결된 질문

24.05.01 21:39 작성

·

85

0

아래와 같이 작성후 navbar 버튼을 클릭해도 타이틀은 변경되지만, 화면 변경이 안됩니다.

 return Scaffold(
      appBar: AppBar(
        title: Obx(() => Text(controller.title.value)),
      ),
      body: SafeArea(
        child: PageTransitionSwitcher(
            transitionBuilder: (Widget child, Animation<double> anim,
                Animation<double> secondAnim) {
              return FadeThroughTransition(
                animation: secondAnim,
                secondaryAnimation: secondAnim,
                child: child,
              );
            },
            child:
                Obx(() => RouteInfo.navBarPages[controller.navBarIdx.value])),
      ),
      bottomNavigationBar: Obx(() => NavigationBar(
            selectedIndex: controller.navBarIdx.value,
            onDestinationSelected: controller.onChangeNavBar,
            destinations: [
              NavigationDestination(
                icon: const Icon(Icons.home_filled),
                label: 'navBar.home'.tr,
              ),
              NavigationDestination(
                icon: const Icon(Icons.list_alt),
                label: 'navBar.post'.tr,
              ),
              NavigationDestination(
                icon: const Icon(Icons.photo),
                label: 'navBar.photo'.tr,
              ),
            ],
          )),
    );

답변 1

0

Sirius B님의 프로필 이미지
Sirius B
지식공유자

2024. 05. 02. 02:22

안녕하세요 Gavin님,

시리우스 B입니다.

저의 강의를 수강해 주셔서 정말 감사합니다!


작성해주신 코드에 오타가 하나 있어서 안되는 것 같습니다.

FadeThroughTransition

animation: secondAnim 부분을

animation: anim 으로 고치면 정상적으로 화면 전환이 될 것으로 보입니다.


작성해주신 코드의 해당 부분이 secondaryAnimation 항목과 같아서 문제가 생긴 것으로 보여요.

한번 해보시고 그래도 안 되면, 다시 한번 문의 주시기 바랍니다.

감사합니다!

 

[반영된 코드]

return Scaffold(
      appBar: AppBar(
        title: Obx(() => Text(controller.title.value)),
      ),
      body: SafeArea(
        child: PageTransitionSwitcher(
            transitionBuilder: (Widget child, Animation<double> anim,
                Animation<double> secondAnim) {
              return FadeThroughTransition(
                animation: anim,
                secondaryAnimation: secondAnim,
                child: child,
              );
            },
            child:
                Obx(() => RouteInfo.navBarPages[controller.navBarIdx.value])),
      ),
      bottomNavigationBar: Obx(() => NavigationBar(
            selectedIndex: controller.navBarIdx.value,
            onDestinationSelected: controller.onChangeNavBar,
            destinations: [
              NavigationDestination(
                icon: const Icon(Icons.home_filled),
                label: 'navBar.home'.tr,
              ),
              NavigationDestination(
                icon: const Icon(Icons.list_alt),
                label: 'navBar.post'.tr,
              ),
              NavigationDestination(
                icon: const Icon(Icons.photo),
                label: 'navBar.photo'.tr,
              ),
            ],
          )),
    );
Gavin님의 프로필 이미지
Gavin
질문자

2024. 05. 04. 01:32

감사합니다. 오타였엇네요.

Gavin님의 프로필 이미지

작성한 질문수

질문하기