当前位置:网站首页>Shutter: action feedback
Shutter: action feedback
2022-07-02 17:14:00 【J_ D_ Chi】
Write it at the front
stay Android or iOS On the device , The system will provide feedback of sound or vibration to help us make users operate , It plays a role of informing the user that this operation is effective . This article is mainly summarized in Flutter On , How to use these functions .
Content
Feedback
Generally we use GestureDetector Will use it onTap or onLongTap Method , Now we can use FeedBack Class to help us add platform specific feedback .
class WidgetWithWrappedHandler extends StatelessWidget {
const WidgetWithWrappedHandler({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: Feedback.wrapForTap(_onTapHandler, context),
onLongPress: Feedback.wrapForLongPress(_onLongPressHandler, context),
child: const Text('X'),
);
}
void _onTapHandler() {
// Respond to tap.
}
void _onLongPressHandler() {
// Respond to long press.
}
}
According to the current official documents Feedback Introduction of methods , stay Android On , Click to play the click system sound , Long press, there will be vibration feedback . And in the iOS There will be no feedback , because iOS There is usually no response to these two operations .
Feedback Two other methods are also provided forTap and forLongPress, To further help us do more work on feedback , For example, judge whether there are other conditions for this operation , To implement feedback .
class WidgetWithExplicitCall extends StatelessWidget {
const WidgetWithExplicitCall({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
// Do some work (e.g. check if the tap is valid)
Feedback.forTap(context);
// Do more work (e.g. respond to the tap)
},
onLongPress: () {
// Do some work (e.g. check if the long press is valid)
Feedback.forLongPress(context);
// Do more work (e.g. respond to the long press)
},
child: const Text('X'),
);
}
}
HapticFeedback
stay Flutter Of services In the bag , There is one HapticFeedback class , There are several static methods , Used to provide vibration feedback :
class HapticFeedback {
static Future<void> vibrate();
static Future<void> lightImpact();
static Future<void> mediumImpact();
static Future<void> heavyImpact();
static Future<void> selectionClick();
}
These methods are also Flutter Used in some official components of , For example, pull-down refresh , Adjust the time in the time selector .
Reference resources
Feedback class
HapticFeedback class
【Flutter Little knowledge 】 Vibration feedback HapticFeedback
边栏推荐
- How openharmony starts FA of remote devices
- 你想要的宏基因组-微生物组知识全在这(2022.7)
- 电脑自带软件使图片底色变为透明(抠图白底)
- In MySQL and Oracle, the boundary and range of between and precautions when querying the date
- 宝宝巴士创业板IPO被终止:曾拟募资18亿 唐光宇控制47%股权
- 对接保时捷及3PL EDI案例
- Just a coincidence? The mysterious technology of apple ios16 is even consistent with the products of Chinese enterprises five years ago!
- Cell:清华程功组揭示皮肤菌群的一种气味挥发物促进黄病毒感染宿主吸引蚊虫...
- 寒门再出贵子:江西穷县考出了省状元,做对了什么?
- 【Leetcode】14. Longest Common Prefix
猜你喜欢

剑指 Offer 26. 树的子结构

DigiCert SSL证书支持中文域名申请吗?

綠竹生物沖刺港股:年期內虧損超5億 泰格醫藥與北京亦莊是股東

电脑自带软件使图片底色变为透明(抠图白底)

Go zero micro service practical series (VIII. How to handle tens of thousands of order requests per second)

宝宝巴士创业板IPO被终止:曾拟募资18亿 唐光宇控制47%股权

剑指 Offer 25. 合并两个排序的链表
![John blasting appears using default input encoding: UTF-8 loaded 1 password hash (bcrypt [blowfish 32/64 x3])](/img/4c/ddf7f8085257d0eb8766dbec251345.png)
John blasting appears using default input encoding: UTF-8 loaded 1 password hash (bcrypt [blowfish 32/64 x3])

【征文活动】亲爱的开发者,RT-Thread社区喊你投稿啦

The macrogenome microbiome knowledge you want is all here (2022.7)
随机推荐
[essay solicitation activity] Dear developer, RT thread community calls you to contribute
13、Darknet YOLO3
亚马逊云科技 Community Builder 申请窗口开启
Configure MySQL under Linux to authorize a user to access remotely, which is not restricted by IP
电脑自带软件使图片底色变为透明(抠图白底)
P6774 [noi2020] tears in the era (block)
一文看懂:数据指标体系的4大类型
Serial port controls steering gear rotation
剑指 Offer 22. 链表中倒数第k个节点
lsf基础命令
Configure ARP table entry restrictions and port security based on the interface (restrict users' private access to fool switches or illegal host access)
The impact of telecommuting on all aspects of our experience | community essay solicitation
pwm呼吸燈
What will you do after digital IC Verification?
绿竹生物冲刺港股:年期内亏损超5亿 泰格医药与北京亦庄是股东
Un an à dix ans
Role and function of uboot
如何与博格华纳BorgWarner通过EDI传输业务数据?
The computer comes with software to make the background color of the picture transparent (matting white background)
OpenHarmony如何启动远程设备的FA