'flutter_slide_animation' is a package that provides animated slide transitions for widgets in Flutter.
Installation
To use this package, add flutter_slide_animation as a dependency in your pubspec.yaml file:
dependencies: flutter: sdk: flutter flutter_slide_animation: ^0.0.1 # Replace with the latest version
Getting started
Import
import 'package:flutter_slide_animation/flutter_slide_animation.dart';
Usage
import 'package:flutter/material.dart';
import 'package:flutter_slide_animation/flutter_slide_animation.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Slide Animation',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
bool animate = false;
void _animateButton() {
setState(() {
animate = !animate;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: const Text('Slide Animation'),
),
body: Center(
child: SlideAnimation(
isAnimate: animate,
slideDirection: SlideDirection.up,
child: ElevatedButton(onPressed: () {
_animateButton();
}, child: const Text('Animate me'),)
),
),
);
}
}
Additional information
Developer: Baqar Naqvi Email: naqvibaqar74@gmail.com