Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- class DragButton extends StatelessWidget {
- String title, route;
- bool isRight = false;
- DragButton({this.title, this.route});
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- onPanUpdate: (details) {
- if (details.delta.dx > 0) {
- isRight = true;
- return print("direita");
- }
- },
- child: Draggable(
- maxSimultaneousDrags: isRight == true ? 1 : 0,
- feedbackOffset: Offset(100, 0),
- axis: Axis.horizontal,
- child: Container(
- width: MediaQuery.of(context).size.width / 1.8,
- height: 50,
- decoration: BoxDecoration(
- color: Colors.amber[700],
- borderRadius: BorderRadius.only(
- topRight: Radius.circular(30),
- bottomRight: Radius.circular(30)),
- ),
- child: Center(
- child: Container(
- child: Text(title,
- style: TextStyle(
- color: Colors.white,
- fontWeight: FontWeight.w700,
- fontSize: 16,
- )))),
- ),
- feedback: Container(
- width: MediaQuery.of(context).size.width / 1.8,
- height: 50,
- decoration: BoxDecoration(
- color: Colors.amber[700],
- borderRadius: BorderRadius.only(
- topRight: Radius.circular(30),
- bottomRight: Radius.circular(30)),
- ),
- child: Center(
- child: Container(
- child: Text(
- title,
- style: TextStyle(
- color: Colors.white, fontWeight: FontWeight.w600, fontSize: 20),
- ))),
- ),
- childWhenDragging: Container(
- width: MediaQuery.of(context).size.width / 1.7,
- height: 50,
- decoration: BoxDecoration(
- color: Colors.amber[700],
- borderRadius: BorderRadius.only(
- topRight: Radius.circular(30),
- bottomRight: Radius.circular(30)),
- ),
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement