项目作者: Tkko

项目描述 :
Flutter page widget that is dismissed by swipe gestures, with Hero style animations, Inspired by FB, IG stories.
高级语言: Dart
项目地址: git://github.com/Tkko/Flutter_dismissible_page.git
创建时间: 2021-02-14T09:20:32Z
项目社区:https://github.com/Tkko/Flutter_dismissible_page

开源协议:Other

下载



Flutter Dismissible Page From Tornike










Pub package
Github starts
style: effective dart
pub package

Flutter widget that allows you to dismiss page to any direction, forget the boring back button and
plain transitions.

Features:

  • Dismiss to any direction
  • Works with nested list view
  • Animating border
  • Animating background
  • Animating scale

Support

PRs Welcome

Discord Channel

Don’t forget to give it a star ⭐

Demo

Live Demo Multi Direction Vertical

Getting Started

  1. const imageUrl =
  2. 'https://user-images.githubusercontent.com/26390946/155666045-aa93bf48-f8e7-407c-bb19-bc247d9e12bd.png';
  3. class FirstPage extends StatelessWidget {
  4. @override
  5. Widget build(BuildContext context) {
  6. return Scaffold(
  7. backgroundColor: Color.fromRGBO(228, 217, 236, 1),
  8. body: GestureDetector(
  9. onTap: () {
  10. // Use extension method to use [TransparentRoute]
  11. // This will push page without route background
  12. context.pushTransparentRoute(SecondPage());
  13. },
  14. child: Center(
  15. child: SizedBox(
  16. width: 200,
  17. // Hero widget is needed to animate page transition
  18. child: Hero(
  19. tag: 'Unique tag',
  20. child: Image.network(
  21. imageUrl,
  22. fit: BoxFit.cover,
  23. ),
  24. ),
  25. ),
  26. ),
  27. ),
  28. );
  29. }
  30. }
  31. class SecondPage extends StatelessWidget {
  32. @override
  33. Widget build(BuildContext context) {
  34. return DismissiblePage(
  35. onDismissed: () {
  36. Navigator.of(context).pop();
  37. },
  38. // Note that scrollable widget inside DismissiblePage might limit the functionality
  39. // If scroll direction matches DismissiblePage direction
  40. direction: DismissiblePageDismissDirection.multi,
  41. isFullScreen: false,
  42. child: Hero(
  43. tag: 'Unique tag',
  44. child: Image.network(
  45. imageUrl,
  46. fit: BoxFit.cover,
  47. ),
  48. ),
  49. );
  50. }
  51. }

Properties

  1. const DismissiblePage({
  2. required this.child,
  3. required this.onDismissed,
  4. this.onDragStart,
  5. this.onDragEnd,
  6. this.onDragUpdate,
  7. this.isFullScreen = true,
  8. this.disabled = false,
  9. this.backgroundColor = Colors.black,
  10. this.direction = DismissiblePageDismissDirection.vertical,
  11. this.dismissThresholds = const <DismissiblePageDismissDirection, double>{},
  12. this.dragStartBehavior = DragStartBehavior.down,
  13. this.dragSensitivity = 0.7,
  14. this.minRadius = 7,
  15. this.minScale = .85,
  16. this.maxRadius = 30,
  17. this.maxTransformValue = .4,
  18. this.startingOpacity = 1,
  19. this.hitTestBehavior = HitTestBehavior.opaque,
  20. this.reverseDuration = const Duration(milliseconds: 200),
  21. Key? key,
  22. }) : super(key: key);
  23. /// Called when the widget has been dismissed.
  24. final VoidCallback onDismissed;
  25. /// Called when the user starts dragging the widget.
  26. final VoidCallback? onDragStart;
  27. /// Called when the user ends dragging the widget.
  28. final VoidCallback? onDragEnd;
  29. /// Called when the widget has been dragged. (0.0 - 1.0)
  30. final ValueChanged<DismissiblePageDragUpdateDetails>? onDragUpdate;
  31. /// If true widget will ignore device padding
  32. /// [MediaQuery.of(context).padding]
  33. final bool isFullScreen;
  34. /// The minimum amount of scale widget can have while dragging
  35. /// Note that scale decreases as user drags
  36. final double minScale;
  37. /// The minimum amount fo border radius widget can have
  38. final double minRadius;
  39. /// The maximum amount of border radius widget can have while dragging
  40. /// Note that radius increases as user drags
  41. final double maxRadius;
  42. /// The amount of distance widget is able to drag. value (0.0 - 1.0)
  43. final double maxTransformValue;
  44. /// If true the widget will ignore gestures
  45. final bool disabled;
  46. /// Widget that should be dismissed
  47. final Widget child;
  48. /// Background color of [DismissiblePage]
  49. final Color backgroundColor;
  50. /// The amount of opacity [backgroundColor] will have when start dragging the widget.
  51. final double startingOpacity;
  52. /// The direction in which the widget can be dismissed.
  53. final DismissiblePageDismissDirection direction;
  54. /// The offset threshold the item has to be dragged in order to be considered
  55. /// dismissed. default is [_kDismissThreshold], value (0.0 - 1.0)
  56. final Map<DismissiblePageDismissDirection, double> dismissThresholds;
  57. /// Represents how much responsive dragging the widget will be
  58. /// Doesn't work on [DismissiblePageDismissDirection.multi]
  59. final double dragSensitivity;
  60. /// Determines the way that drag start behavior is handled.
  61. final DragStartBehavior dragStartBehavior;
  62. /// The amount of time the widget will spend returning to initial position if widget is not dismissed after drag
  63. final Duration reverseDuration;
  64. /// How to behave during hit tests.
  65. ///
  66. /// This defaults to [HitTestBehavior.opaque].
  67. final HitTestBehavior hitTestBehavior;