slide_to_submit_button 1.0.3

SDKflutter
Platformandroidioswindowslinuxmacosweb

A customizable slide-to-submit button with animation and styling options.

Slide To Submit

A highly customizable and animated slide-to-submit button for your Flutter applications. This widget provides a sleek and intuitive way for users to confirm actions.


✨ Features

  • Smooth sliding animation
  • Bouncy return animation on release
  • Customizable text and styling
  • Callback on successful submission
  • Animated arrow indicator

🚀 Getting Started

Installation

In your pubspec.yaml file, add the following dependency:

dependencies:
  slide_to_submit: ^1.0.0

Then, run:

flutter pub get

🔧 Usage

Here's a simple example of how to use the SlideToSubmit:

import 'package:flutter/material.dart';
import 'package:slide_to_submit/slide_to_submit.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Slide To Submit Example'),
        ),
        body: Center(
          child: SlideToSubmit(
            onSubmit: (controller) {
              // controller.reset(); // Reset the slider after submission
              // controller.done(); // Dispose the controller if no longer needed
              print("Submitted!");
            },
          ),
        ),
      ),
    );
  }
}

🎨 Customization

The SlideToSubmit widget offers two constructors: a default constructor for quick use and a custom constructor for full control.

Default Constructor

PropertyTypeDescription
onSubmitVoidCallbackRequired. Callback triggered on successful submission.
textString?Optional label inside the slider.
textStyleTextStyleStyle for the slider text.
sliderIconIconData?Icon shown in the slider.
sliderIconColorColorColour of the icon inside the slider.
backgroundColorColorBackground color of the full widget.
foregroundColorColorForeground (slider) color.
borderRadiusBorderRadiusCorner radius for both background and slider.
heightdoubleTotal height of the widget.
sliderWidthdoubleWidth of the draggable slider.
thresholddoubleRatio of slide distance needed to trigger submit (0.0 to 1.0).
bounceDurationDurationDuration of bounce-back animation when not submitted.
showArrowboolWhether to show an animated arrow hint.
paddingEdgeInsetsGeometryPadding around the widget.

Custom Constructor (SlideToSubmit.custom)

Use this when you want to design your own slider widget.

PropertyTypeDescription
onSubmitVoidCallbackRequired. Callback triggered on successful submission.
sliderWidgetRequired. Your own custom slider widget.
sliderWidthdoubleWidth of your custom slider.
backgroundDecorationBoxDecorationDecoration for the outer container.
foregroundDecorationBoxDecorationDecoration for the slider.
hintWidget?Optional hint like an arrow or label.
heightdoubleHeight of the widget.
thresholddoubleRatio of slide distance needed to trigger submit.
bounceDurationDurationDuration of bounce-back animation.
paddingEdgeInsetsGeometryPadding around the widget.

📷 Screenshots

Slide Demo


💡 Example

Check out the example/ directory for a full working implementation.


🛠️ Contributing

This package is open source. Contributions are welcome!

  • Fork the repository
  • Create a feature branch
  • Commit your changes
  • Open a pull request

📄 License

MIT © Abdullah Al Mamun


👥 Maintainer


Made with ❤️ using Flutter.