flutter_easy_popup

一种简单的方法来显示 Flutter 自定义弹出窗口小部件。

截图

示例 截图
下拉菜单 dropdown
App操作指南 guide
多重高亮 multi_highlights
加载
loading

示例

您可以通过以下命令运行示例。

cd ./example
flutter create .
flutter run

入门

dependencies:
  easy_popup: ^1.0.0

或者

dependencies:
  easy_popup: 
    git: https://github.com/BakerJQ/flutter_easy_popup.git

用法

定义自定义弹出窗口小部件

使用EasyPopupChild定义自定义弹出窗口小部件,并实现dismiss函数,该函数在关闭时执行需要完成的工作,例如显示关闭动画。

class CustomWidget extends StatefulWidget with EasyPopupChild {

  ...

  @override
  dismiss() {
    ...
  }
}

调用显示

调用EasyPopup.show()将您的组件显示为弹出窗口。

EasyPopup.show(context, CustomWidget());

调用pop

调用EasyPopup.pop()来关闭弹出窗口。

EasyPopup.pop(context);

参数

参数 描述
context BuildContext
child 您的弹出窗口小部件
offsetLT 深色背景的左侧和顶部偏移量
offsetRB 深色背景的右侧和底部偏移量
cancelable 弹出窗口是否可以通过触摸外部区域或按Android上的后退按钮来关闭
darkEnable 是否显示深色背景
duration 动画显示持续时间
highlights 要显示高亮区域的矩形

GitHub

https://github.com/BakerJQ/flutter_easy_popup