목표

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

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

댓글 남기기

  • Mastering the Fundamentals of Object-Oriented Programming in C++

    [Tutorial] · 2026-01-15 04:15 UTC Mastering the Fundamentals of Object-Oriented Programming in C++ 💡 TL;DR Learn how to structure your code with classes, define objects, encapsulate data, and leverage inheritance for efficient development. 📚 Learning Objectives This tutorial introduces object-oriented programming concepts in C++, focusing on classes, objects, encapsulation, and inheritance. You’ll gain practical skills…

  • Building Your First Web App with Flask: A Simple To-Do List Example

    [Tutorial] · 2026-01-15 03:11 UTC Building Your First Web App with Flask: A Simple To-Do List Example 💡 TL;DR Learn how to create a simple web app with Flask by building a “To-Do List” example using code examples. 📚 Learning Objectives This tutorial teaches beginners how to build a basic web application using Flask, a…

  • Mastering Python Data Structures: Lists, Tuples, and Dictionaries

    [Tutorial] · 2026-01-15 02:08 UTC Mastering Python Data Structures: Lists, Tuples, and Dictionaries 💡 TL;DR Learn how to use lists, tuples, and dictionaries in Python to store, organize, and access data effectively. 📚 Learning Objectives This tutorial introduces essential Python data structures (lists, tuples, dictionaries) for organizing and manipulating data efficiently. It provides hands-on examples…

  • Mastering Python’s List Comprehensions for Efficient Code Writing

    [Tutorial] · 2026-01-15 01:06 UTC Mastering Python’s List Comprehensions for Efficient Code Writing 💡 TL;DR Learn how list comprehensions streamline your Python code by creating lists automatically from iterables. 📚 Learning Objectives This tutorial will introduce you to list comprehensions in Python, empowering you to create concise code that builds lists based on existing iterables.…

  • Mastering Web Design Basics: HTML & CSS for Beginners

    Welcome to my website! This is a simple introductory paragraph.

← 뒤로

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

TechTinkerer's에서 더 알아보기

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

계속 읽기

TechTinkerer's에서 더 알아보기

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

계속 읽기