목표

  • Flutter에서 애니메이션의 기본 개념.
  • AnimatedContainer 위젯을 사용하여 간단한 애니메이션을 구현.
  • Hero 위젯으로 화면 전환 트랜지션 효과 적용.

1.애니메이션의 기본 개념

Flutter에서는 애니메이션을 사용하여 UI를 더 역동적으로 만들 수 있습니다. Flutter는 프레임워크에 내장된 다양한 애니메이션 도구를 제공하며, 이를 통해 간단한 움직임부터 복잡한 트랜지션까지 구현할 수 있습니다.

Flutter 애니메이션 종류

1.1 암시적 애니메이션:

  • AnimateContainer, AnimateOpacity 등 애니메이션이 포함된 위젯.
  • 코드가 간단하고 구현이 쉽다.

1.2 명시적 애니메이션:

  • AnimationController와 Tween을 사용하여 세부적으로 제어.
  • 더 복잡한 애니메이션을 구현할 때 사용.

2. AnimatedContainer 위젯

AnimatedContainer는 상태 변화에 따라 부드러운 전환을 자동으로 처리합니다.

새로운 프로젝트 또는 이전 프로젝트의 소스코드를 다음과 같이 작성합니다.

결과

  • 버튼 클릭 시 AnimatedContainer가 크기와 색상을 부드럽게 전한합니다.
  • duration 속성으로 애니메이션의 시간을 설정합니다.
  • curve 속성으로 애니메이션의 동작을 설정합니다.(예: Curves.easeInOut).

3. Hero 위젯

Hero 위제은 화면 전환 시 특정 위젯 간의 애니메이션을 제공합니다

3.1 MainPage에서 SecodPage로 전환하며 이미지 이동 효과를 구현해보겠습니다.

MainPage 코드를 다음과 같이 작성해보세요

SecondPage 소스코드

결과

  • MainPage에서 이미지를 클릭하면 SecondPage로 이동하며 이미지가 부드럽게 확대됩니다.
  • Hero 위젯의 tag 속성이 동일한 위젯 간에 애니메이션을 연결합니다.

4. 실습

1단계: 위치 이동 애니메이션 구현

  • AnimatedContainer를 사용하여 버튼 클릭 시 사각형이 화면 왼쪽으로 이동하도록 구현하세요.
  • 힌트
    • AnimatedContainer의 aligment 속성을 변경합니다.
    • 예: Aligment.center –> Aligment.centerLeft()

2단계: Hero 위젯 확장

  • Hero 위젯을 사용하여 이미지뿐만 아니라 텍스트를 함께 이동시키도록 해보세요.
  • 힌트:
    • Column으로 이미지와 텍스트를 그룹화하고 Hero 위젯을 묶으세요.
    • 두 패이지 모두 같은 Tag를 사용해야 애니메이션이 연결됩니다.

5. 결론

이번에는 Flutter에서 간단한 애니메이션을 구현하는 방법과 전환 트랜지션을 배웠습니다. 이를 통해 역동적인 효과를 추가할 수 있습니다. 다음 시간에는 Flutter 네트워킹 및 HTTP 요청 처리를 알아 보겠습니다.

감사합니다.


TechTinkerer's에서 더 알아보기

구독을 신청하면 최신 게시물을 이메일로 받아볼 수 있습니다.

댓글 남기기

  • **South Korean Diplomat Returns to US After 70 Days**

    The United States and South Korea have welcomed back a key diplomat, Kevin Kim, who served as the country’s special representative to the US. Kim’s return comes after a nearly one-year absence from his post, during which time Washington struggled to find a suitable replacement. Kim’s departure in January last year was widely seen as…

  • The Fate of Greenland hangs in the Balance: A Global Power Play

    The fate of Greenland has become a focal point of global politics, with multiple nations vying for control over the strategic island. In recent weeks, several countries have expressed interest in acquiring or partnering with Greenland to further their interests. This article will examine the situation and explore the potential implications for international relations. The…

  • **South Korea’s Ambassador to the US Returns from Absence**

    After a year-long vacancy, South Korean Ambassador to the United States Kevin Kim has returned to his post. The ambassador’s return comes as a welcome relief for the South Korean government, which had been without an ambassador to the US since Kim’s departure in 2022. The cause of Kim’s absence was not publicly disclosed, but…

  • Building a Dynamic Landing Page: Mastering HTML, CSS, & JavaScript

    Welcome to My Website This is a basic landing page example. Click Me!

  • Mastering File Input/Output in C++

    [Tutorial] · 2026-01-15 08:44 UTC Mastering File Input/Output in C++ 💡 TL;DR Learn how to read from and write to files in C++ using the ifstream and ofstream objects, along with clear explanations of key concepts. 📚 Learning Objectives This tutorial explores file input/output operations in C++, covering essential concepts, practical examples, and best practices…

← 뒤로

응답해 주셔서 감사합니다. ✨

TechTinkerer's에서 더 알아보기

지금 구독하여 계속 읽고 전체 아카이브에 액세스하세요.

계속 읽기

TechTinkerer's에서 더 알아보기

지금 구독하여 계속 읽고 전체 아카이브에 액세스하세요.

계속 읽기