showWidget static method
Displays a Widget on the screen that can persist across multiple pages.
toastBuilder
is the builder function to generate the Widget to be displayed.
key
represents a credential for this Toast. With this key, you can remove the Widget defined by the current key using remove.
groupKey
represents a group key, mainly used for removeAll and remove.
CancelFunc is the close function, and actively calling it will close this Toast.
This is a core method.
显示一个Widget在屏幕上,该Widget可以跨多个页面存在
toastBuilder
生成需要显示的Widget的builder函数
key
代表此Toast的一个凭证,凭此key可以删除当前key所定义的Widget,remove
groupKey
代表分组的key,主要用于removeAll和remove
CancelFunc 关闭函数,主动调用将会关闭此Toast
这是个核心方法
Implementation
static CancelFunc showWidget({required ToastBuilder toastBuilder, UniqueKey? key, String? groupKey}) {
final gk = groupKey ?? defaultKey;
final uniqueKey = key ?? UniqueKey();
final CancelFunc cancelFunc = () {
remove(uniqueKey, gk);
};
botToastManager.insert(gk, uniqueKey, toastBuilder(cancelFunc));
return cancelFunc;
}