drag_like 3.0.0 copy "drag_like: ^3.0.0" to clipboard
drag_like: ^3.0.0 copied to clipboard

Flutter左滑右滑/喜欢、不喜欢的特效插件

drag_like #

  1. Flutter左滑右滑/喜欢、不喜欢的特效插件
  2. 支持划出事件回调,通知上层是左边划出还是右边划出
  3. 支持滑动进度回调
  4. 支持第二层widget缩放完成回调,缩放完成时刷新数据
  5. 支持手指抬起回调
  6. 支持手速检测,速度超过指定值后,卡片将会划出屏幕,已解决手速不准确问题(感谢@DoodleBears贡献代码)
  7. null safety
  8. 支持控制控制左右划出
  9. 支持设置滑出动画执行时长
  10. 支持控制器左右划出时,自定义回调参数

安装 #

在工程 pubspec.yaml 中加入 dependencies

dependencies:
  drag_like: ^last version

效果图 #

使用方法 #

DragLike(
  dragController: _dragController,
  duration: Duration(milliseconds: 520),
  child: imagelist.length <=0 ? Text('加载中...') : ClipRRect(
    borderRadius: BorderRadius.circular(10),
    child: TestDrag(src:imagelist[0])
  ), 
  secondChild: imagelist.length <= 1 ? Container(): ClipRRect(
    borderRadius: BorderRadius.circular(10),
    child:TestDrag(src:imagelist[1])
  ), 
  allowDrag: true,
  screenWidth: 375, 
  outValue: 0.6,
  dragSpeedRatio: 80,
  onChangeDragDistance: (distance){
    /// {distance: 0.17511112467447917, distanceProgress: 0.2918518744574653}
    print(distance.toString());
  },
  onOutComplete: (type){
    /// left or right
    print(type);
  },
  onScaleComplete: (){
    imagelist.remove(imagelist[0]);
    if(imagelist.length == 0) {
      loaddata();
    }
    setState(() {});
  },
  onPointerUp: (){
    
  },
  onCancel: (){
	print('取消了');
  },
),

回调方法 #

onOutComplete #

onOutComplete: (type){
	/// left or right
	print(type);
},

onScaleComplete #

onScaleComplete: (){
	imagelist.remove(imagelist[0]);
	if(imagelist.length == 0) {
		loaddata();
	}
	setState(() {});
},

onChangeDragDistance #

  1. distance滑动距离,0-1,超过设置的值将会划出widget
  2. distanceProgress,根据设置的划出边界值的百分比,0-1+,方便做一些特效,超过1即代表松手就会划出边界

onChangeDragDistance: (distance){
	/// {distance: 0.17511112467447917, distanceProgress: 0.2918518744574653}
	print(distance.toString());
},

onPointerUp #

onPointerUp: (){

},

onCancel #

onCancel: (){

},

控制器 #


_dragController.toLeft(completeTag: 'custom_left');

_dragController.toRight(completeTag: 'custom_right');

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

7
likes
125
pub points
43%
popularity

Publisher

verified publisherbanai.com.cn

Flutter左滑右滑/喜欢、不喜欢的特效插件

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-2-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on drag_like