slide_to_confirm 1.1.0 slide_to_confirm: ^1.1.0 copied to clipboard
A slider that will activate a callback when the user slides it to 100%.
import 'package:flutter/material.dart';
import 'package:slide_to_confirm/slide_to_confirm.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
debugShowCheckedModeBanner: false,
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void confirm() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Container(
color: Colors.blueAccent.withOpacity(0.5),
),
Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Center(
child: Text(
_counter.toString(),
style: TextStyle(
fontSize: 38,
color: Colors.white,
),
),
),
Center(
child: Container(
margin: EdgeInsets.only(top: 50, bottom: 100),
child: ConfirmationSlider(
onConfirmation: () => confirm(),
),
),
),
],
),
],
),
);
}
}