목표

  • 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에서 더 알아보기

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

댓글 남기기

  • Build Your First Website from Scratch using HTML & CSS

    Hello, World! This is my first website.

  • Building a Simple Web Page: HTML & CSS Fundamentals

    Welcome to My Website This is a basic web page example.

  • Introduction to Data Science Concepts in C++

    [Tutorial] · 2026-01-13 23:41 UTC Introduction to Data Science Concepts in C++ 💡 TL;DR Explore fundamental data science concepts like arrays, strings, and basic math functions in C++, opening doors to practical data manipulation tasks. 📚 Learning Objectives This tutorial provides an introduction to key data science concepts in C++, including arrays, strings, and mathematical…

  • Building a Simple Game in C++: Beginner’s Guide to Object Oriented Programming and Graphic Design

    [Tutorial] · 2026-01-13 23:20 UTC Building a Simple Game in C++: Beginner’s Guide to Object Oriented Programming and Graphic Design 💡 TL;DR Learn how to create basic games using C++ by exploring object-oriented programming and drawing on the screen! 📚 Learning Objectives This tutorial will introduce beginners to game development using C++, covering basic programming…

  • Unveiling C++’s Power for Data Science

    [Tutorial] · 2026-01-13 08:25 UTC Unveiling C++’s Power for Data Science 💡 TL;DR Discover how to manipulate data efficiently using C++’s array, string, and math features for impactful data-driven solutions. 📚 Learning Objectives This tutorial introduces fundamental C++ concepts crucial for data science applications, focusing on arrays, strings, and mathematical functions. 🎯 Key Concepts Arrays…

← 뒤로

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

TechTinkerer's에서 더 알아보기

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

계속 읽기

TechTinkerer's에서 더 알아보기

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

계속 읽기