多次点击可在加载第一个共享屏幕时打开多个共享屏幕

我应用了共享包来共享一些我想在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'),
zhuzhuxiangw 回答:多次点击可在加载第一个共享屏幕时打开多个共享屏幕

嗨,

您应该使用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)
                },
本文链接:https://www.f2er.com/3144894.html

大家都在问