flushbar icon indicating copy to clipboard operation
flushbar copied to clipboard

Dismiss function on Flushbar not working?

Open renrique92 opened this issue 3 years ago • 1 comments

I been trying to make a dismiss button on the toast but is not working

Here is my code of my Factory:

static Flushbar toastFactory(ToastSettings settings) { _flush = Flushbar( messageText: settings.highlightedText != null ? RichText( text: TextSpan( style: TextStyle( fontWeight: FontWeight.bold, fontSize: FONT_BODY_SIZE, ), text: settings.highlightedText, children: [ TextSpan( text: ' ${settings.message}', style: TextStyle( fontWeight: FontWeight.normal, fontSize: FONT_BODY_SIZE, )), ], ), ) : HFText(settings.message), duration: settings.duration, icon: settings.icon, flushbarPosition: settings.position, backgroundColor: settings.type.color, dismissDirection: _dismissDirection(settings.position), shouldIconPulse: false, borderRadius: 4, onStatusChanged: (status) { if (status == FlushbarStatus.DISMISSED) { _busy = false; if (settings.dismissCallback != null) settings.dismissCallback(); } }, flushbarStyle: _toastStyle(settings.position), mainButton: HFIconButton.streched( icon: HeroFinder.hf_close, onPressed: () => _flush.dismiss(), ), onTap: (flushbar) { flushbar.dismiss(); }, ); return _flush; }

I tried to use the onTap and nothing happended

renrique92 avatar Jul 31 '20 23:07 renrique92

You're referencing the wrong object in your dismiss call (missing an underscore):

onTap: (flushbar) {
  flushbar.dismiss(); // should be: _flushbar.dismiss(); 
},

Next time, by the way, please use backward quotes (`) - or three backward quotes (```) for a code block - to make your code more readable when posting an issue.

benPesso avatar Oct 01 '20 10:10 benPesso