在屏幕上的任何位置显示弹出窗口,或将您的弹出窗口附加到小部件上!

Alt TextAlt Text

特点

  • 在屏幕上的任何位置显示任何小部件(弹出窗口)。
  • 将您的弹出窗口附加到小部件上,并使用该小部件将其移动到任何位置。(即将推出!)
  • 自定义弹出窗口内容的进入和退出过渡效果,以及持续时间和曲线。
  • 在各种类型的弹出窗口背景(障碍物)之间进行选择,例如阻止与后面小部件交互的背景和不阻止的背景。
  • 如果选择这样做,则支持将弹出窗口限制在可见屏幕区域内。
  • 该软件包经过了充分的测试和文档记录。

用法

await showSimplePopup(
      context: context,
      content: Container(),// Put any widget here
      contentOffsetBuilder: (Size contentSize) {
        //  return the position you want for the top left of the widget you returned above
        //  you also have the size of that widget to use in your calculations!
      },
      transitionBuilder: (context, animation, secondaryAnimation, child){
        // create any transition 
        // child is the widget returned above, i.e. the content of your popup
        // don't forget to pass it the child as well
    },
      transitionDuration: const Duration(milliseconds: 1000),
      reverseTransitionDuration: const Duration(milliseconds: 300),
      transitionCurve: Curves.easeInOutBack,
      reverseTransitionCurve: Curves.easeOutExpo,
      modalBarrierBehavior: HitTestBehavior.translucent,// popup's empty area will dismiss the popup and pass through the tap
    );

即将推出

  • 能够将弹出窗口附加到另一个小部件。

注意事项

  • 弹出窗口被推送到一个新的路由上,因此它的上下文将不同,所以当您想将其他路由的状态更新反映到弹出窗口的路由时,您必须记住这一点。例如,在这种情况下,您可以使用StatefulBuilderProvider或任何其他状态管理解决方案。

附加信息

欢迎您为该软件包做出贡献。只需提交一个PR,包含您认为将为软件包增加价值的功能或修复。

GitHub

查看 Github