Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. class DragButton extends StatelessWidget {
  4. String title, route;
  5. bool isRight = false;
  6. DragButton({this.title, this.route});
  7. @override
  8. Widget build(BuildContext context) {
  9. return GestureDetector(
  10. onHorizontalDragUpdate: (direction){
  11. var sentido = direction.localPosition.dx;
  12. if(sentido > 0){
  13. isRight = true;
  14. print("O sentido é direita $sentido");
  15. }
  16. else if(sentido < 0){
  17. isRight = false;
  18. }
  19. },
  20. child: Draggable(
  21.  
  22. maxSimultaneousDrags: isRight ? 1 : 0,
  23. feedbackOffset: Offset(100, 0),
  24. axis: Axis.horizontal,
  25. child: Container(
  26. width: MediaQuery.of(context).size.width / 1.8,
  27. height: 50,
  28. decoration: BoxDecoration(
  29. color: Colors.amber[700],
  30. borderRadius: BorderRadius.only(
  31. topRight: Radius.circular(30),
  32. bottomRight: Radius.circular(30)),
  33. ),
  34. child: Center(
  35. child: Container(
  36. child: Text(title,
  37. style: TextStyle(
  38. color: Colors.white,
  39. fontWeight: FontWeight.w700,
  40. fontSize: 16,
  41. )))),
  42. ),
  43. feedback: Container(
  44. width: MediaQuery.of(context).size.width / 1.8,
  45. height: 50,
  46. decoration: BoxDecoration(
  47. color: Colors.amber[700],
  48. borderRadius: BorderRadius.only(
  49. topRight: Radius.circular(30),
  50. bottomRight: Radius.circular(30)),
  51. ),
  52. child: Center(
  53. child: Container(
  54. child: Text(
  55. title,
  56. style: TextStyle(
  57. color: Colors.white, fontWeight: FontWeight.w600, fontSize: 20),
  58. ))),
  59. ),
  60. childWhenDragging: Container(
  61. width: MediaQuery.of(context).size.width / 1.7,
  62. height: 50,
  63. decoration: BoxDecoration(
  64. color: Colors.amber[700],
  65. borderRadius: BorderRadius.only(
  66. topRight: Radius.circular(30),
  67. bottomRight: Radius.circular(30)),
  68. ),
  69. ),
  70. ),
  71. );
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement