animated_infinite_slider 0.0.1
animated_infinite_slider: ^0.0.1 copied to clipboard
An advanced Flutter animation package to create an infinite, draggable slider for showcasing any widget list (e.g., images, cards, or custom widgets). The slider supports seamless animations, draggabl [...]
π Infinite Draggable Slider π #
An advanced Flutter animation package to create an infinite, draggable slider for showcasing any widget list (e.g., images, cards, or custom widgets). The slider supports seamless animations, draggable interactions, and customization options to suit your app's design.
β¨ Features #
- Infinite Sliding: Navigate through widgets in an infinite loop.
- Draggable Interaction: Drag left or right to navigate, with threshold-based sensitivity.
- Smooth Animations: Fine-tuned transitions for a polished look and feel.
- Snapback Behavior: Widgets snap back to their original position when dragged vertically.
- Highly Customizable: Control dimensions, animations, and padding as per your requirements.
π¦ Installation #
Add the package to your pubspec.yaml
file:
dependencies:
animated_slider: latest_version
Run the command:
flutter pub get
π οΈ Usage #
Hereβs how you can integrate the slider into your project:
import 'package:animated_slider/animated_slider.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const HomeScreen(),
);
}
}
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
final List<String> imageList = List.generate(10, (index) {
return "assets/images/image${index + 1}.jpg";
});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 100),
const Text("π Animated Slider Widget π"),
Expanded(
child: AnimatedSlider(
itemCount: imageList.length,
itemBuielder: (context, index) =>
SliderImages(image: imageList[index]),
),
),
const SizedBox(height: 100),
],
),
),
);
}
}
class SliderImages extends StatelessWidget {
const SliderImages({super.key, required this.image});
final String image;
@override
Widget build(BuildContext context) {
return Container(
height: 400,
width: 250,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(18),
image: DecorationImage(image: AssetImage(image), fit: BoxFit.contain),
),
);
}
}
π§° Properties #
Property | Type | Description |
---|---|---|
itemCount |
int |
Total number of items in the slider. |
itemBuielder |
Function(BuildContext context, int index) |
Function to build each widget. |
height |
double? |
(Optional) Height of the slider. |
width |
double? |
(Optional) Width of the slider. |
padding |
EdgeInsets? |
(Optional) Padding inside the slider. Default: 8.0 . |
onTap |
Function? |
(Optional) Callback for tap events. |
index |
int |
(Optional) Initial index of the slider. Default: 0 . |
π Asset Setup #
Make sure your image assets are properly defined in the pubspec.yaml
file:
flutter:
assets:
- assets/images/image1.jpg
- assets/images/image2.jpg
- assets/images/image3.jpg
For a folder:
flutter:
assets:
- assets/images/
π License #
This project is licensed under the MIT License.
π Contributing #
Contributions are welcome! Feel free to open issues or submit pull requests.
π₯ Demo #
Include a demo GIF or image to showcase your slider in action! #
Happy Sliding! π
Key Changes: #
- Updated the properties to reflect the improved code (
height
spelling fixed). - Added drag sensitivity and animation refinements in the highlights section.
- Simplified and aligned the code examples with the latest functionality.
- Suggested adding a demo GIF to make the project more visually appealing.