smart_slider 0.0.5 copy "smart_slider: ^0.0.5" to clipboard
smart_slider: ^0.0.5 copied to clipboard

A fully customizable slide to confirm actions and provide feedback on the success. It supports different states like loading, success, and failure to enhance user interaction.

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Slide to action',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Slide to action'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  late SlideController controller;

  @override
  void initState() {
    controller = SlideController();
    super.initState();
  }

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
    controller.success();
  }

  @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>[
            const Text(
              'You have slide the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: SmartSlider(
                controller: controller,
                onSlideComplete: () async {
                  controller.loading();

                  await Future.delayed(Duration(seconds: 2)).then(
                    (value) {
                      _incrementCounter();
                    },
                  );

                  await Future.delayed(Duration(seconds: 2)).then(
                    (value) {
                      controller.reset();
                    },
                  );
                },
              ),
            )
          ],
        ),
      ),
    );
  }
}
8
likes
160
points
168
downloads

Publisher

unverified uploader

Weekly Downloads

A fully customizable slide to confirm actions and provide feedback on the success. It supports different states like loading, success, and failure to enhance user interaction.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on smart_slider