flushbar
flushbar copied to clipboard
Dismiss function on Flushbar not working?
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
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.