);
return GestureDetector(
key: _key,
onTapDown: (detail) {
setState(() {
if (canAddFavorite) {
print(‘添加爱心,当前爱心数量:${icons.length}’);
icons.add(_p(detail.globalPosition));
widget.onAddFavorite?.call();
justAddFavorite = true;
} else {
justAddFavorite = false;
}
});
},
onTapUp: (detail) {
timer?.cancel();
var delay = canAddFavorite ? 1200 : 600;
timer = Timer(Duration(milliseconds: delay), () {
canAddFavorite = false;
timer = null;
if (!justAddFavorite) {
widget.onSingleTap?.call();
}
});
canAddFavorite = true;
},
onTapCancel: () {
print(‘onTapCancel’);
},
child: Stack(
children: [
widget.child,
iconStack,
],
),
);
}
}
class TikTokFavoriteAnimationIcon extends StatefulWidget {
final Offset position;
final double size;
final Function onAnimationComplete;
const TikTokFavoriteAnimationIcon({
Key key,
this.onAnimationComplete,
this.position,
this.size: 100,
}) : super(key: key);
@override