Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 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. onPanUpdate: (details) {
  11. if (details.delta.dx > 0) {
  12. isRight = true;
  13. return print("direita");
  14. }
  15. },
  16. child: Draggable(
  17. maxSimultaneousDrags: isRight == true ? 1 : 0,
  18. feedbackOffset: Offset(100, 0),
  19. axis: Axis.horizontal,
  20. child: Container(
  21. width: MediaQuery.of(context).size.width / 1.8,
  22. height: 50,
  23. decoration: BoxDecoration(
  24. color: Colors.amber[700],
  25. borderRadius: BorderRadius.only(
  26. topRight: Radius.circular(30),
  27. bottomRight: Radius.circular(30)),
  28. ),
  29. child: Center(
  30. child: Container(
  31. child: Text(title,
  32. style: TextStyle(
  33. color: Colors.white,
  34. fontWeight: FontWeight.w700,
  35. fontSize: 16,
  36. )))),
  37. ),
  38. feedback: Container(
  39. width: MediaQuery.of(context).size.width / 1.8,
  40. height: 50,
  41. decoration: BoxDecoration(
  42. color: Colors.amber[700],
  43. borderRadius: BorderRadius.only(
  44. topRight: Radius.circular(30),
  45. bottomRight: Radius.circular(30)),
  46. ),
  47. child: Center(
  48. child: Container(
  49. child: Text(
  50. title,
  51. style: TextStyle(
  52. color: Colors.white, fontWeight: FontWeight.w600, fontSize: 20),
  53. ))),
  54. ),
  55. childWhenDragging: Container(
  56. width: MediaQuery.of(context).size.width / 1.7,
  57. height: 50,
  58. decoration: BoxDecoration(
  59. color: Colors.amber[700],
  60. borderRadius: BorderRadius.only(
  61. topRight: Radius.circular(30),
  62. bottomRight: Radius.circular(30)),
  63. ),
  64. ),
  65. ),
  66. );
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement