showPop function

void showPop({
  1. required BuildContext context,
  2. required List<Widget> items,
  3. double? top,
  4. double? left,
  5. double? right,
  6. double width = 100,
  7. double cellHeight = 40,
  8. Color backgroundColor = Colors.white,
  9. Color dividerColor = const Color(0xFFE6E6E6),
  10. required Color barrierColor,
  11. bool hiddenArrow = false,
  12. bool barrierDismissible = true,
  13. ClickCallBack? clickCallback,
})

Implementation

void showPop({
  required BuildContext context,
  required List<Widget> items,
  double? top,
  double? left,
  double? right,
  double width = 100,
  double cellHeight = 40,
  Color backgroundColor = Colors.white,
  Color dividerColor = const Color(0xFFE6E6E6),
  required Color barrierColor,
  bool hiddenArrow = false,
  bool barrierDismissible = true,
  ClickCallBack? clickCallback,
}) {
  Widget _buildMenuLineCell(dataArr) {
    return MediaQuery.removePadding(
      context: context,
      removeTop: true,
      child: ListView.separated(
        itemCount: dataArr.length,
        physics: const NeverScrollableScrollPhysics(),
        itemBuilder: (BuildContext context, int index) {
          return GestureDetector(
              onTap: () {
                Navigator.pop(context);
                if (clickCallback != null) {
                  clickCallback(index);
                }
              },
              child: Container(
                height: cellHeight,
                margin: EdgeInsets.only(
                  left: 10,
                ),
                child: Align(
                  alignment: Alignment.centerLeft,
                  child: dataArr[index],
                ),
              ));
        },
        separatorBuilder: (context, index) {
          return Divider(
            height: 0.1,
            color: dividerColor,
          );
        },
      ),
    );
  }

  showPopView(
    context: context,
    widget: _buildMenuLineCell(items),
    top: top,
    left: left,
    right: right,
    width: width,
    height: cellHeight * items.length,
    backgroundColor: backgroundColor,
    barrierColor: barrierColor,
    hiddenArrow: hiddenArrow,
    barrierDismissible: barrierDismissible,
  );
}