Slider Button Widget for Flutter

You are currently viewing Slider Button Widget for Flutter
Slider Button

Slider Button Widget for Flutter

This package provides an easy implementation of a Slider Button to cancel current transaction or screen. Highly customizable iphone alike looking widget.

Slider Button
Slider Button

How to use

Type 1

This is a Circle type widget. You just need to define the border radius to swap between rectangle and circle type widget.

Slider Button
Slider Button
import 'package:slider_button/slider_button.dart';
Center(child: SliderButton(
      action: () {
        ///Do something here
        Navigator.of(context).pop();
      },
       label: Text(
          "Slide to cancel Event",
          style: TextStyle(
              color: Color(0xff4a4a4a), fontWeight: FontWeight.w500, fontSize: 17),
        ),
      icon: Text(
        "x",
        style: TextStyle(
          color: Colors.white,
          fontWeight: FontWeight.w400,
          fontSize: 44,
        ),
      ),


    ));

Type 2

This is a Rectangle type widget.

Slider Button
Slider Button
import 'package:slider_button/slider_button.dart';
SliderButton(
      action: () {
        ///Do something here OnSlide
      },

      ///Put label over here
      label: Text(
        "Slide to cancel !",
        style: TextStyle(
            color: Color(0xff4a4a4a),
            fontWeight: FontWeight.w500,
            fontSize: 17),
      ),
      icon: Center(
          child: Icon(
        Icons.power_settings_new,
        color: Colors.white,
        size: 40.0,
        semanticLabel: 'Text to announce in accessibility modes',
      )),

      ///Change All the color and size from here.
      width: 230,
      radius: 10,
      buttonColor: Color(0xffd60000),
      backgroundColor: Color(0xff534bae),
      highlightedColor: Colors.white,
      baseColor: Colors.red,
    );

Custom Usage

There are several options that allow for more control:

See also  Play music/audio stored in assets files (simultaneously) directly from Flutter
PropertiesDefaultDescription
actionnull(required) Define an action after slidding a button
childnullFor more customizable button add your own widget
vibrationFlagfalsecontrols vibration on successful dismissed
heightnull ?? 70Gives a height to a widget
widthnull ?? 250Gives a width to a widget
backgroundColorColor(0xffececec)Gives a background color to a widget
baseColorColor(0xff4a4a4a)Gives a shimmer base color to a widget
highlightedColorColors.whiteGives a shimmer highlighted color to a widget
buttonColorColors.blackGives a color to a slidder button
labelnullA text widget which assigns a label.
alignLabelAlignment(0.4, 0)Aligns text label
boxShadownullGives a shadow to a slidder button
iconnullA widget to provide an icon to a button
shimmerfalseenables/disables shimmer effect on the label
dismissibletrueMake it false if you want maintain the widget in the tree
buttonSizenull ?? 60Gives size to a button
dismissThresholds1.0The offset threshold when it should be considered dismissed

Credit

This is developed by anirudhsharma392
Download this project from the below link.
https://github.com/anirudhsharma392/Slider-Button/archive/refs/heads/master.zip
You can visit original source page from the below link:
https://github.com/anirudhsharma392/Slider-Button

Spread the love

Leave a Reply