可点击的 Widget
这个 Flutter 插件提供了一些带有手势处理器的 Widget。
默认情况下,一些 Flutter Widget(无手势 Widget)不会触发手势事件,因此我们将其包装在 InkWell/GestureDetector Widget 中。为了解决这个问题,我决定构建一个包,直接在 WWG 中为开发人员提供一些手势处理器。
可用的手势处理器
onTap;onTapDown;onTapUp;onTapCancelonDoubleTapDownonDoubleTaponDoubleTapCancelonLongPressDownonLongPressCancelonLongPressonLongPressStartonLongPressMoveUpdateonLongPressUponLongPressEnd
可用的 Widget
- ClickableContainer
- ClickableImage
- ClickableCard
- ClickableGridTile
- ClickableSizedBox
用法
在 `dependencies` 部分将 Clickable Widget 添加到您的 pubspec.yaml 文件中。
dependencies:
clickable_widget: 0.0.2
更新依赖项
$ flutter pub get
在您的代码中导入 Clickable Container Widget
ClickableContainer(
onTap: () {
debugPrint("container tapped");
},
alignment: Alignment.center,
width: 100.0,
height: 100.0,
color: Colors.grey,
child: const Text("Tap me!"),
),
在您的代码中导入 Clickable Image Widget
ClickableImage(
onTap: () {
debugPrint("network image tapped");
},
clickableImageType: ClickableImageType.network,
src: "https://pixabay.com/fr/images/search/nature/",
),
在您的代码中导入 Clickable GridTile Widget
ClickableGridTile(
onTap: () {
debugPrint("grid tile tapped");
},
child: const Text("Tap me!"),
),
元信息
Gael Vinou [email protected]
- Twitter @gael_vinou
- LinkedIn Gael Vinou
https://github.com/GV-22/clickable_widget
根据 BSD-3-Clause 分发
贡献
- Fork 它 (https://github.com/GV-22/clickable_widget/fork)
- 创建你的功能分支 (
git checkout -b feature/fooBar) - 提交你的更改 (
git commit -am 'Add some fooBar') - 推送到分支 (
git push origin feature/fooBar) - 创建一个新的 Pull Request