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(
- onHorizontalDragUpdate: (direction){
- var sentido = direction.localPosition.dx;
- if(sentido > 0){
- isRight = true;
- print("O sentido é direita $sentido");
- }
- else if(sentido < 0){
- isRight = false;
- }
- },
- child: Draggable(
- maxSimultaneousDrags: isRight ? 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