show static method

_Show show(
  1. BuildContext context
)

Implementation

static _Show show(BuildContext context) {
  final int notifyDuration = WeUi.getConfig(context).notifyDuration;
  return ({Color? color, int? duration, required child}) {
    final GlobalKey widgetKey = GlobalKey();
    final Function remove = createOverlayEntry(
        context: context,
        child: NotifyWidget(
            key: widgetKey,
            color: color == null ? WeUi.getTheme(context).warnColor : color,
            child: child));

    void close() async {
      // 反向执行动画
      await (widgetKey.currentState as NotifyWidgetState).reverseAnimation();
      remove();
    }

    Future.delayed(
        Duration(milliseconds: duration == null ? notifyDuration : duration),
        close);
  };
}