Flutter - Slide Transition Widget
Last Updated :
28 Apr, 2025
In this article, we will explore the Flutter Slide Transition Widget. The Slide Transition widget allows animating a widget's position relative to its normal position. It helps us to develop a visually appealing and interactive user Interface. A sample video is given below to get an idea about what we are going to do in this article.
Step By Step Implementation
Step 1: Open your VS-code create a Flutter Application And Installing Module using the following steps:
- Open the Command Palette (Ctrl+Shift+P (Cmd+Shift+P on macOS)).
- Select the Flutter: New Project command and press Enter.

- Select Application and press Enter.

- Select a Project location.
- Enter your desired Project name.
Now your project structure looks like this:
Step 2: Create a SlideTransition widget by writing the following code inside your main.dart file
Dart
import 'package:flutter/material.dart';
// Entry point of Flutter Application
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the
// root of your application.
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Slide Transition Widget',
home: SlideTransitionWidget(),
);
}
}
// SlideTransitionWidget---> StateFul class
class SlideTransitionWidget extends StatefulWidget {
const SlideTransitionWidget({super.key});
@override
State<SlideTransitionWidget> createState() => _SlideTransitionWidgetState();
}
// uses the SingleTikerProvider Mixin
class _SlideTransitionWidgetState extends State<SlideTransitionWidget>
with SingleTickerProviderStateMixin {
// defining the Animation Controller
late final AnimationController _controller = AnimationController(
duration: const Duration(seconds: 2),
vsync: this,
)..repeat(reverse: true);
// defining the Offset of the animation
late final Animation<Offset> _offsetAnimation = Tween<Offset>(
begin: Offset.zero,
end: const Offset(1.5, 0.0),
).animate(CurvedAnimation(
parent: _controller,
curve: Curves.elasticIn,
));
// After using disposing the controller
// is must to releasing the resourses
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
// Scaffold Widget
return Scaffold(
appBar: AppBar(
title: const Text('SlideTransition Sample'),
backgroundColor: Colors.green),
body: Center(
child: SlideTransition(
// the offset which we define above
position: _offsetAnimation,
child: Padding(
padding: const EdgeInsets.all(8.0),
// Loading the GeeksForGeeks logo
child: Image.network(
'https://media.geeksforgeeks.org/wp-content/cdn-uploads/20210419113249/gfg-new-logo-min.png'),
),
)),
);
}
}
Now let's understand the complete code:
import 'package:flutter/material.dart
We import flutter/material.dart package so that we can implement the material design, we can use widgets like stateless widgets, materialApp, etc.
void main() {
runApp(const MyApp());
}
Every flutter code has an entry point from the main function, inside the main function we call the runApp method provided by 'flutter/material.dart' Â package and we pass the widget MyApp as a parameter.
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Slide Transition Widget',
home: SlideTransitionWidget(),
);
}
}
Now we create our stateless widget MyApp by extending the stateless widget class provided by the material.dart package, then we override the build method implemented in statelessWidget class and return the materialApp widget with the required parameters.
late final AnimationController _controller = AnimationController(
duration: const Duration(seconds: 2),
vsync: this,
)..repeat(reverse: true);
Initializing the Animation Controller. Animation Controller takes duration helps us to define the duration of the animation, "repeat(reverse: true)" means animation is repeating and in reverse too.
late final Animation<Offset> _offsetAnimation = Tween<Offset>(
begin: Offset.zero,
end: const Offset(1.5, 0.0),
).animate(CurvedAnimation(
parent: _controller,
curve: Curves.elasticIn,
));
Here we define the offset of the animation using the Tween
@override
void dispose() {
_controller.dispose();
super.dispose();
}
Disposing the controllers to releasing the resources
Scaffold(
appBar: AppBar(
title: const Text('SlideTransition Sample'),
backgroundColor: Colors.green),
body: Center(
child: SlideTransition(
position: _offsetAnimation,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Image.network(
'https://media.geeksforgeeks.org/wp-content/cdn-uploads/20210419113249/gfg-new-logo-min.png'),
),
)),
);
representing the app bar, setting the color of the AppBar, in the center defining the SlideTrasition widget, and inside that we load the geeksforgeeks logo.
Step 3: Run the following code by selecting the Android emulator or on your physical device by connecting it.
Output Screenshot:
Output Video:
Similar Reads
Flutter Tutorial This Flutter Tutorial is specifically designed for beginners and experienced professionals. It covers both the basics and advanced concepts of the Flutter framework.Flutter is Googleâs mobile SDK that builds native Android and iOS apps from a single codebase. It was developed in December 2017. When
7 min read
Dart Tutorial Dart is an open-source general-purpose programming language developed by Google. It supports application development on both the client and server side. However, it is widely used for the development of Android apps, iOS apps, IoT(Internet of Things), and web applications using the Flutter Framework
7 min read
Top 50 Flutter Interview Questions and Answers for 2025 Flutter is an open-source, cross-platform application development framework. It was developed by Google in 2017. It is used to build applications for Android, iOS, Linux, Mac, Windows, and the web. Flutter uses the Dart programming language. It provides a simple, powerful, efficient, and easy-to-und
15+ min read
What is Widgets in Flutter? Flutter is Google's UI toolkit for crafting beautiful, natively compiled iOS and Android apps from a single code base. To build any application we start with widgets - The building block of Flutter applications. Widgets describe what their view should look like given their current configuration and
5 min read
Flutter | An introduction to the open source SDK by Google Flutter is Googleâs Mobile SDK to build native iOS and Android, Desktop (Windows, Linux, macOS), and Web apps from a single codebase. When building applications with Flutter, everything is Widgets â the blocks with which the flutter apps are built. They are structural elements that ship with a bunch
5 min read
Android Studio Setup for Flutter Development This article will show how to set up Android Studio to run Flutter Applications. Android Studio is one of the popular IDE( integrated development environment  ) developed by Google itself to create cross-platform Android applications. First, you have to install Android Studio version 3.0 or later, a
3 min read
Dart - Data Types Like other languages (C, C++, Java), whenever a variable is created, each variable has an associated data type. In Dart language, there are the types of values that can be represented and manipulated in a programming language. In this article, we will learn about Dart Programming Language Data Types
8 min read
Flutter - Architecture Application Flutter architecture application mainly consists of: WidgetsGesturesConcept of StateLayersWidgetsWidgets are the primary component of any flutter application. It acts as a UI for the user to interact with the application. Any flutter application is itself a widget that is made up of a combination of
3 min read
Dart SDK Installation To do a lot of interesting programming stuff using the Dart programming language, we have to install the Dart SDK. Dart SDK is a pre-compiled version so we have to download and extract it only. In this article, we will learn how to perform Dart SDK Download.Table of ContentInstall Dart SDK in Window
4 min read
Dart - Standard Input Output In Dart programming language, you can take standard input from the user through the console via the use of the .readLineSync() function. To take input from the console you need to import a library, named dart:io from the libraries of Dart.Stdin ClassThis class allows the user to read data from stand
3 min read