パッケージ、リポジトリ、アプリカテゴリを検索

GitHub リポジトリMohammadJamali/draggable_carousel_slider

ドラッグ可能なカルーセルスライダー

ドラッグ可能なカルーセルスライダーのFlutterウィジェットで、ループとカスタム子ウィジェットをサポートしています。

ドラッグ可能なカルーセルスライダー のプロジェクト画像
スター
3
フォーク
7
最終プッシュ(UTC)
2024/09/30
プロジェクト状態
公開中

元の README

以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。

Draggable Carousel Slider

Draggable Carousel Slider is a Flutter package that provides a customizable carousel slider widget with draggable functionality. It allows users to easily create interactive carousel sliders where items can be dragged.

Features

  • Draggable functionality: Items in the carousel slider can be dragged horizontally, providing an interactive user experience.
  • Looping option: The carousel slider supports looping through items, allowing seamless navigation from the last item back to the first.
  • Responsive design: The package includes features for handling various screen sizes and orientations, ensuring a consistent user experience across different devices.
  • Custom child widget: Users can supply their own custom widgets as carousel items, enabling a wide range of design possibilities.

Getting started

To start using the Draggable Carousel Slider package, you can simply add the package to your pubspec.yaml file and import it into your Flutter project.

dependencies:
  ...
  draggable_carousel_slider:

Usage

import 'package:draggable_carousel_slider/draggable_carousel_slider.dart';
import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});
  @override
  State<MyApp> createState() => _MyAppPageState();
}

class _MyAppPageState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  Widget _image(
    String path,
    double width,
    double height, [
    bool shimmer = false,
  ]) =>
      ClipRRect(
        borderRadius: BorderRadius.circular(16),
        child: Image.network(
          path,
          width: width,
          height: height,
          fit: BoxFit.cover,
          loadingBuilder: (
            BuildContext context,
            Widget child,
            ImageChunkEvent? loadingProgress,
          ) => AnimatedCrossFade(
              firstChild: child,
              secondChild: Shimmer.fromColors(
                baseColor: Colors.grey.shade400,
                highlightColor: Colors.grey.shade700,
                enabled: true,
                period: const Duration(seconds: 2),
                child: Container(
                  width: width,
                  height: height,
                  color: Colors.black,
                ),
              ),
              crossFadeState: shimmer ||
                      ((child as Semantics).child as RawImage).image == null
                  ? CrossFadeState.showSecond
                  : CrossFadeState.showFirst,
              duration: const Duration(milliseconds: 300),
            ),
        ),
      );

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.deepPurple,
        ),
        useMaterial3: true,
      ),
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: SafeArea(
          child: Padding(
            padding: const EdgeInsets.symmetric(vertical: 16.0),
            child: Center(
              child: DraggableSlider(
                loop: true,
                children: [
                  _image('https://picsum.photos/id/230/600/600', 300, 300),
                  _image(
                      'https://picsum.photos/id/431/600/600', 300, 300, true),
                  _image('https://picsum.photos/id/232/600/600', 300, 300),
                  _image('https://picsum.photos/id/433/600/600', 300, 300),
                  _image('https://picsum.photos/id/234/600/600', 300, 300),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}

Mohammad GitHub avatar
GitHub 作者

Mohammad ↗

Linux, EF Core, Python, Flutter

言語C++CMakeDartHTMLSwiftCKotlinObjective-C

このリポジトリが公開するパッケージ

使用している依存関係

依存関係一覧 4 件

プロジェクトに合うリポジトリを選ぶには?

用途で絞り込み、開発状況を比較し、採用前に元のリポジトリで要件を確認しましょう。

  1. 名前・作者・説明で検索し、技術トピックで絞り込みます。
  2. スター、フォーク、最近のプッシュを比較します。スターは関心の目安であり、品質の保証ではありません。
  3. 利用前に GitHub で README、ライセンス、Issues を確認します。

情報源と管理

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗