showCustomPoint static method
Future<OverlayEntryManger?>
showCustomPoint({
- BuildContext? context,
- BuildToastStyle? buildToastStyle,
- required BuildToastPoint buildToastPoint,
- int? showTime,
显示自定义坐标的吐司
Implementation
static Future<OverlayEntryManger?> showCustomPoint({
BuildContext? context,
BuildToastStyle? buildToastStyle,
required BuildToastPoint buildToastPoint,
int? showTime,
}) async {
///防止多次弹出,外部设置间隔时间 默认2秒
if (_instance._startedTime != null &&
DateTime.now().difference(_instance._startedTime!).inMilliseconds <
_instance.intervalTime) {
return null;
}
buildToastStyle = buildToastStyle ?? _instance.globalBuildToastStyle;
_instance._startedTime = DateTime.now();
var _overlayEntry = OverlayEntry(
builder: (BuildContext context) =>
buildToastPoint.call(context, buildToastStyle!));
///获取OverlayState
if (context == null) {
///创建和显示顶层OverlayEntry
navigatorState.currentState?.overlay?.insert(_overlayEntry);
} else {
var overlayState = Overlay.of(context);
overlayState.insert(_overlayEntry);
}
var manger = OverlayEntryManger(_overlayEntry);
_overlayEntryMangers.add(manger);
manger
.start(showTime ?? _instance.showTime, _instance._startedTime!)
.then((value) {
_overlayEntryMangers.remove(value);
});
return manger;
}