How To Add Animations Using Animated Align - #10 Flutter Web Tutorial Series By Florian Prümer

Description

How To Add Animations Using Animated Align - #10 Flutter Web Tutorial Series By Florian Prümer

Summary by www.lecturesummary.com: How To Add Animations Using Animated Align - #10 Flutter Web Tutorial Series By Florian Prümer

Creating a Sliding Animation Effect with Animated Align Widget

In this video, the instructor demonstrates how to create a sliding animation effect using the AnimatedAlign

widget in Flutter. The goal is to improve the user interface of a project view by allowing a smooth transition between different project descriptions.

Key Concepts and Takeaways

(00:00:00 - 00:00:11)

  • Introduction to the topic of creating a sliding animation effect using the AnimatedAlign

    widget.

(00:00:11 - 00:00:21)

  • The animation will help improve the user interface of the project view, allowing a nice transition from one project description to another.

  • The code for this project is available in the instructor's GitHub repository, which is provided in the video description.

(00:00:21 - 00:00:36)

  • The instructor encourages the viewer to explore the full potential of the AnimatedAlign

    widget.

(00:00:36 - 00:00:48)

  • The current page layout consists of a column of images, and the goal is to have a horizontal bar sliding up and down depending on which image is clicked.

  • The horizontal bar should always end up in the center of each image, creating "target points" that the animation should hit.

(00:00:48 - 00:01:16)

  • The instructor suggests creating an area that spans from the center of the top image to the center of the bottom image.

  • The target points correspond to the alignment values: top center

    , center

    , and bottom center

    within this area.

  • The only task left is to add a horizontal bar to this area and change its alignment based on the clicked image.

(00:01:16 - 00:01:30)

  • The instructor encourages the viewer to explore the project files and the desktop view.

(00:01:30 - 00:01:45)

  • The current layout has a column of images in a row.

  • The instructor will create another child of this row, which will be the special area mentioned earlier.

  • Some space will be added between the images and a container with a specific height.

(00:01:45 - 00:02:06)

  • The height of the container is set to be twice the size of an image and twice the size of the spaces between each image.

(00:02:06 - 00:02:16)

  • The container is given a width of 5 and a white color to make it visible.

  • After restarting the app, the special area can be seen.

(00:02:16 - 00:02:29)

  • The width and color of the container are removed.

  • The child of this container needs to be something that allows aligning widgets to a specific position.

(00:02:29 - 00:02:41)

  • The instructor uses a Stack

    widget as the child of the container.

  • The only child of the Stack

    widget will be an AnimatedAlign

    widget, with a specified duration and animation curve.

(00:02:41 - 00:03:03)

  • The child of the AnimatedAlign

    widget is a white container representing the horizontal bar.

(00:03:14 - 00:03:28)

  • A dedicated parameter is created to decide the alignment of the horizontal bar.

  • A selectedIndex

    parameter is created and set to 0 as the default.

(00:03:28 - 00:04:04)

  • The AnimatedAlign

    widget's alignment is set based on the selectedIndex

    value:

    • If selectedIndex

      is 0, the alignment is top center

      .

    • If selectedIndex

      is 1, the alignment is center

      .

    • If selectedIndex

      is 2, the alignment is bottom center

      .

(00:04:04 - 00:04:27)

  • A method is created to update the selectedIndex

    when an image is clicked.

  • This method is called from the onPressed

    callback of the image list.

(00:04:27 - 00:04:43)

  • After the changes, the horizontal bar animates as expected when an image is clicked.

(00:04:43 - 00:04:54)

  • The next step is to show a project description based on the currently selected index.

(00:04:54 - 00:05:16)

  • A ProjectEntry

    widget is used to display the project header and description.

  • This widget is added to the Expanded

    widget in the ProjectsView

    file.

(00:05:16 - 00:05:38)

  • After the changes, the app now displays the project description based on the selected index.

(00:05:38 - 00:05:49)

  • The final result shows a nice indication of the currently selected project and an overview of the project details.

(00:05:49 - 00:05:59)

  • The instructor concludes the video and encourages the viewer to ask any questions in the comments.

DeepLearn by www.lecturesummary.com: How To Add Animations Using Animated Align - #10 Flutter Web Tutorial Series By Florian Prümer

Creating a Sliding Animation Effect with Animated Align Widget

Introduction (00:00:00 - 00:00:11)

  • Greetings and welcome to the video

  • We will learn how to create a sliding animation effect using the AnimatedAlign

    widget

Improving Project View (00:00:11 - 00:00:21)

  • The animation will help improve the UI of our project view

  • It will allow for a nice transition from one project description to another

Getting the Code (00:00:21 - 00:00:36)

  • The code for this project is available in the instructor's GitHub repository

  • The link to the repository is provided in the description box

Understanding the AnimatedAlign Widget (00:00:36 - 00:00:48)

  • We have a column of images

  • We want to have a horizontal bar sliding up and down next to the images

Sliding Horizontal Bar (00:00:48 - 00:01:16)

The horizontal bar always:

  • Stays the same size

  • Slides up and down next to the images

  • Aligns with the currently selected image

Key Points:

  • The horizontal bar stays the same size

  • It slides up and down next to the images

  • The bar aligns with the currently selected image

Aligning Images with Target Points

(00:01:16 - 00:01:30)In this section, the speaker discusses the concept of "target points" within images. These target points correspond to the alignment values (top center, center, and bottom center) within a specific area created by the speaker.

Key Points:

  • The center of each image acts as a "target point" that needs to be hit

  • An area is created that spans from the center of the top image to the center of the bottom image

  • The target points correspond to the alignment values (top center, center, bottom center) within this created area

(00:01:30 - 00:01:45)The speaker then explains the next step, which is to add a horizontal bar to the created area and change its alignment based on the image that is clicked.

Steps:

  1. Create another child of the existing row, which will be the "special area" mentioned earlier

  2. Add some space in between the images and a container with a horizontal bar

  3. Adjust the alignment of the horizontal bar based on the image that is clicked

Implementing the Alignment Feature

(00:01:45 - )To implement the alignment feature, the speaker suggests going to the project file and examining the desktop view.

Key Tasks:

  • The current setup has a column of images in a row

  • Create another child of this row, which will be the "special area"

  • Add space in between the images and a container with a horizontal bar

  • Adjust the alignment of the horizontal bar based on the image that is clicked

Implementation Steps:

  1. Go to the project file and open the desktop view

  2. Examine the current setup, which has a column of images in a row

  3. Create another child of this row, which will be the "special area"

  4. Add some space in between the images and a container with a horizontal bar

  5. Adjust the alignment of the horizontal bar based on the image that is clicked

Aligning Widgets in Flutter

Sizing and Positioning Containers

(00:01:45 - 00:02:06)

  • The height of the container is set to be twice the size of the image and the space between the images

  • This allows you to see the layout and positioning of the elements

Styling the Container

(00:02:06 - 00:02:16)

  • Add a width of 5 and a white color to the container

  • This creates an area to play around with the alignment of the widgets

Removing Width and Color

(00:02:16 - 00:02:29)

  • Remove the width and color from the container

  • The child of this container needs to be something that allows us to align widgets to a specific position

Using a Stack Widget

(00:02:29 - 00:02:41)

  • Use a Stack

    widget as the child of the container

  • The only child of the Stack

    widget will be an AnimatedAlign

    widget

  • Set a duration and animation curve for the AnimatedAlign

    widget

Adding a White Container

(00:02:41 - 00:03:03)

  • The child of the AnimatedAlign

    widget will be a white container representing a horizontal bar

Aligning the Horizontal Bar

(00:03:03 - 00:03:14)

  • The goal is to align the horizontal bar within the container

Alignment Configuration

(00:03:14 - 00:03:28)

Description:To configure the alignment of an element, we need to have a dedicated parameter that determines the alignment. We can create a selectedIndex

parameter and set it to 0 as the default value. Then, we can use this parameter to determine the alignment of the element in our AnimatedAlignWidget

.

Key Points:

  • Create a selectedIndex

    parameter and set it to 0 as the default value.

  • Use the selectedIndex

    parameter to determine the alignment of the element in the AnimatedAlignWidget

    .

Alignment Behavior

(00:03:28 - 00:04:04)

Description:Based on the value of the selectedIndex

parameter, we can set the alignment of the element. If the index is 0, the alignment should be center. If the index is 1, the alignment should be top center. If the index is 2, the alignment should be bottom center. The only thing left to do is to change the selectedIndex

parameter to update the alignment.

Key Points:

  • If selectedIndex

    is 0, set the alignment to center.

  • If selectedIndex

    is 1, set the alignment to top center.

  • If selectedIndex

    is 2, set the alignment to bottom center.

  • Change the selectedIndex

    parameter to update the alignment.

Updating the Alignment

(00:04:04 - 00:04:27)

Description:When the user clicks on an image, we need to create a method that takes in a new index

and sets the selectedIndex

parameter to this new value within a setState

call. Then, we need to call this updateIndex

method in the onPressed

callback of the image list.

Key Points:

  • Create a method that takes in a new index

    and sets the selectedIndex

    parameter to this new value within a setState

    call.

  • Call the updateIndex

    method in the onPressed

    callback of the image list.

Restarting the Page

(00:04:27 - 00:04:43)

Description:After restarting the page, we can see that the horizontal bar is now aligned based on the selected index. This means that the alignment configuration and behavior are working as expected.

Key Points:

  • The alignment of the horizontal bar is now updated based on the selected index.

  • The alignment configuration and behavior are working as expected.

Animating and Displaying Project Details

Displaying Project Description (00:04:43 - 00:04:54)

  • We want to display a project description based on the currently selected index

  • This will provide more information about the selected project

Adding a Project Entry Widget (00:04:54 - 00:05:16)

  • Created a project entry widget to display each project

  • Includes a header and corresponding description for each project

  • Can then add an expanded widget to the project's view file

  • Set the project entry based on the currently selected project

Restarting the Application (00:05:16 - 00:05:38)

  • Hit the restart button to see the changes

  • Now have a nice indication of the currently selected project

  • Also have an overview of what the project is all about

Conclusion (00:05:38 - 00:05:59)

  • That's it for today's lesson

  • Thank you for watching, feel free to ask any questions in the comments

  • Have a nice day and hopefully see you next time!