sliding_widget 0.0.5

SDKflutter
Platformandroidioswindowslinuxmacosweb

A sliding Flutter widget, which helps to start an event based on user interaction. Highly customizable and flexible.

pub package

A sliding Flutter widget, which helps to start an event based on user interaction. Highly customizable and flexible.

Features

  • Highly customizable
  • Easy to use

Getting started

  1. Add the dependency.
sliding_widget: ^0.0.5
  1. Import the package.
 import 'package:sliding_widget/sliding_widget.dart';
  1. Use the widget in your code.
 SlidingWidget(
          width: 350,
          height: 60,
          backgroundColor: Colors.blue,
          foregroundColor: Colors.white,
          iconColor: Colors.blue,

          /// Text to be displayed inside the button.
          text: 'Slide to proceed',

          shadow: const BoxShadow(color: Colors.transparent),

          /// Accepts function, default is null, this property is required.
          action: () {},

          child: const Icon(Icons.arrow_forward_ios),
          
          /// Whether the icon to be fixed at the end.
          stickToEnd: false,
        ) 

Usage

This full code is from the example folder. You can run the example to see.

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});
  final String title;
  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            SlidingWidget(
              width: 350,
              height: 60,
              backgroundColor: Colors.blue,
              foregroundColor: Colors.white,
              iconColor: Colors.blue,
              text: 'Slide to proceed',
              shadow: const BoxShadow(color: Colors.transparent),
              action: () {},
              child: const Icon(Icons.arrow_forward_ios),
            )
          ],
        ),
      ),
    );
  }
}

Custom Usage

There are several options that allows for more control:

PropertiesDefaultDescription
heightnull ?? 70Gives a height to a widget
widthnull ?? 300Gives a width to a widget
backgroundColorColors.whiteGives a background color to a widget
backgroundColorEndnullGives a background color to a widget while dragged
foregroundColorColors.blueAccentGives a color to a slider button
labelSlide to proceedA text widget which assigns a label
labelStyleColors.white70, FontWeight.boldAssigns label TextStyle
shadowColors.black38, Offset(0, 2), blurRadius: 2Gives a shadow to a slider button
stickToEndfalseMake it true if the Icon need to be placed in the end position
actionnull(required) Define an action after sliding a button
childIcons.chevron_rightFor more customizable button add your own widget
foregroundShapeBorderRadius.all(Radius.circular(widget.height / 2))Gives shape to the child widget through BorderRadius
backgroundShapeBorderRadius.all(Radius.circular(widget.height))Gives shape to the background widget through BorderRadius
onTapDownnullAdd action when user interacts with the widget
onTapUpnullAdd action when user interacts with the widget