hz_kit

Last updated:

0 purchases

hz_kit Image
hz_kit Images
Add to Cart

Description:

hz kit

一些常用的工具集合,可能包括一些算法,函数或小组件等。
Getting started #
在 pubspec.yaml 中添加依赖
dependencies:
hz_kit: ^0.0.1
copied to clipboard
然后在终端执行 flutter pub get
在需要使用的地方 import
import 'package:hz_kit/hz_kit.dart';
copied to clipboard
Usage #
debounce:某个函数在某段时间内,无论触发了多少次回调,都只执行最后一次
debounce(
() {
print('function fired');
},
time: const Duration(milliseconds: 600),
onCancel: () {
print('Click canceled');
},
);
copied to clipboard
throttle 节流函数,先触发函数,然后在一定时间内不触发,过了一定时间后再触发
throttle(
() {
print('function fired');
},
time: const Duration(seconds: 2),
onIgnored: () {
print('ignored');
},
onLocked: () {
print('locked');
},
onUnlocked: () => print('unlocked'),
);
copied to clipboard
throttleFuture 节流函数变种,在异步函数执行期间不接受下一次调用
throttleFuture(
() async {
print('function fired');
await Future.delayed(const Duration(seconds: 2));
print('function done');
},
onIgnored: () {
print('ignored');
},
onLocked: () {
print('locked');
},
onUnlocked: () => print('unlocked'),
);
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.