reorderable_mixin.dart 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import 'package:flutter/widgets.dart';
  2. import 'transitions.dart';
  3. mixin ReorderableMixin {
  4. @protected
  5. Widget makeAppearingWidget(
  6. Widget child,
  7. AnimationController entranceController,
  8. Size? draggingFeedbackSize,
  9. Axis direction,
  10. ) {
  11. if (null == draggingFeedbackSize) {
  12. return SizeTransitionWithIntrinsicSize(
  13. sizeFactor: entranceController,
  14. axis: direction,
  15. child: FadeTransition(
  16. opacity: entranceController,
  17. child: child,
  18. ),
  19. );
  20. } else {
  21. var transition = SizeTransition(
  22. sizeFactor: entranceController,
  23. axis: direction,
  24. child: FadeTransition(opacity: entranceController, child: child),
  25. );
  26. BoxConstraints contentSizeConstraints = BoxConstraints.loose(draggingFeedbackSize);
  27. return ConstrainedBox(constraints: contentSizeConstraints, child: transition);
  28. }
  29. }
  30. @protected
  31. Widget makeDisappearingWidget(
  32. Widget child,
  33. AnimationController ghostController,
  34. Size? draggingFeedbackSize,
  35. Axis direction,
  36. ) {
  37. if (null == draggingFeedbackSize) {
  38. return SizeTransitionWithIntrinsicSize(
  39. sizeFactor: ghostController,
  40. axis: direction,
  41. child: FadeTransition(
  42. opacity: ghostController,
  43. child: child,
  44. ),
  45. );
  46. } else {
  47. var transition = SizeTransition(
  48. sizeFactor: ghostController,
  49. axis: direction,
  50. child: FadeTransition(opacity: ghostController, child: child),
  51. );
  52. BoxConstraints contentSizeConstraints =
  53. BoxConstraints.loose(draggingFeedbackSize);
  54. return ConstrainedBox(
  55. constraints: contentSizeConstraints, child: transition);
  56. }
  57. }
  58. }