flutter - 加载第一个共享屏幕时多次单击打开多个共享屏幕
问题描述
我应用了共享包来共享一些我想在 android 和 IoS 中打开共享屏幕时显示加载器的数据。如果用户在显示共享屏幕之前多次单击它会打开多个共享屏幕。
ListTile(
title: Row(
children: <Widget>[
Icon(
Icons.thumbs_up_down,
color: DrawerIconsText,
size: 24.0,
),
SizedBox(
width: 10,
),
Text('Share App'),
],
),
onTap: () =>
Share.share('Share this data'),
),
解决方案
嗨,
你应该使用 Statefulwidget 扩展来解决这个问题。
例如:
// change your class extends to Statefulwidget
bool _isShare = false;
@override
didupdatewidget(){
// change duration time up to you
if (_isShare)
new Timer(const Duration(milliseconds: 400), () {
setState(()=> _isShare = false);
});
}
ListTile(
title: Row(
children: <Widget>[
Icon(
Icons.thumbs_up_down,
color: DrawerIconsText,
size: 24.0,
),
SizedBox(
width: 10,
),
Text('Share App'),
],
),
onTap: () {
if (!_isShare) Share.share('Share this data');
setState(() = _isShare = true)
},
),
推荐阅读
- powershell - 需要输出一个 PowerShell 脚本的结果
- c++ - 为什么 ThreadSanitizer (TSAN) 在 Glib::signal_idle().connect_once 上报告数据竞争
- flutter - 尝试初始化 Hive 时出现奇怪的错误
- sql-server - 如何从特定模式(T SQL)中的所有表中删除特定的公共记录?
- javascript - 使用 JavaScript、HTML 和 CSS 突出显示单词
- c - 我的程序在调试时运行正确,但在调试结束时运行不正确
- excel - 与 Excel 相比,Python 中的数据透视表具有不同的格式
- javascript - webkitEnterFullScreen 与 requestFullscreen 浏览器可用性
- linux - 使用 linux 不会崩溃,而是像在 windows 中一样冻结
- c - 使用 OpenMP 减少数组会导致“未找到用户定义的减少”