搜索插件、代码仓与 APP 分类

custom_pointed_popup 封面
插件详情v0.0.4

custom_pointed_popup

可显示在任何目标小部件上的弹出窗口,具有自定义的指针设计。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
116
喜欢数
23
Pub 分数
130

安装插件

flutter pub add custom_pointed_popup

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,可实现将可自定义的带指针弹出框锚定到任何特定控件上。它支持带有方向指针的独特设计,非常适合用于工具提示或上下文提示。弹出框可以精确地相对于其目标位置进行定位,并且在所有主要平台(包括移动、Web 和桌面)上都兼容。它通过提供视觉反馈来增强用户体验,而不会中断 UI 流程。

适合场景

  • 在按钮上显示提示工具
  • 创建自定义上下文菜单
  • 突出显示表单字段
  • 提供交互式指导
  • 在小部件附近显示动态信息

主要特点

  • 可自定义指针形状
  • 相对于目标 Widget 的精确位置
  • 对多种平台渲染的支持
  • 通过自定义组件实现可扩展设计
  • 平滑的动画过渡

适合对象

  • 寻求交互元素的UI/UX设计师
  • 开发人员构建引导式入门流程
  • 需要上下文帮助系统的应用
  • 具有丰富交互界面的项目
  • 使用 Flutter 开发跨平台应用的团队

使用建议

  • 需要仔细的布局管理
  • 复杂设计可能需要额外的样式
  • 大量同时弹出窗口带来的性能影响
  • 有限的内置主题,需要自定义实现
  • 由于尺寸限制,不适合用于大内容区域

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

custom_pointed_popup

Popup that can be shown on any targeted widget with customized pointed design.

Screenshots

alt text alt text alt text alt text

Getting Started

Example
  final GlobalKey widgetKey = GlobalKey();

  CustomPointedPopup getCustomPointedPopup(BuildContext context) {
    return CustomPointedPopup(
      backgroundColor: Colors.red,
      context: context,
      lineColor: Colors.tealAccent,
      widthFractionWithRespectToDeviceWidth: 3,
      displayBelowWidget: true,
      triangleDirection: TriangleDirection.FullLeft,
      popupElevation: 10,

      ///you can also add border radius
      ////popupBorderRadius:,
      item: CustomPointedPopupItem(
        title: 'Popup that can be shown on any targeted widget with customized pointed design.',
        textStyle: Theme.of(context).textTheme.caption!.copyWith(
              color: Theme.of(context).cardColor,
            ),
        iconWidget: Icon(
          Icons.add_moderator,
          color: Theme.of(context).cardColor,
        ),

        ///Or you can add custom item widget below instead above 3
        ///itemWidget: Container(),
      ),
      onClickWidget: (onClickMenu) {
        print('popup item clicked');
      },
      onDismiss: () {
        print('on dismissed called');
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          'Custom Pointed Popup [CPP]',
        ),
      ),
      body: Container(
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(
                'CPP with straight pointer & item.',
                style: TextStyle(
                  color: Colors.red,
                  fontSize: 14.0,
                  fontStyle: FontStyle.italic,
                  fontWeight: FontWeight.bold,
                ),
              ),
              SizedBox(
                height: 40,
              ),
              GestureDetector(
                onTap: () {
                  getCustomPointedPopup(context)
                    ..show(
                      widgetKey: widgetKey,
                    );
                },
                child: Card(
                  key: widgetKey,
                  elevation: 10,
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(20),
                  ),
                  child: Container(
                    height: 100,
                    width: 100,
                    child: Center(
                      child: Text(
                        'Click Me \nTo\n Display CPP',
                        textAlign: TextAlign.center,
                        overflow: TextOverflow.clip,
                        style: TextStyle(
                          color: Colors.blueGrey,
                          fontWeight: FontWeight.w900,
                          fontSize: 14.0,
                        ),
                      ),
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }

Important Class, Function And Enum

The important class to know. CustomPointedPopupItem - Model item to display inside the pointed popup:

Attribute Type Default Required Description
iconWidget Widget No This will create an icon inside the pointed popup.
title String No Title or text for the pointed popup.
textStyle TextStyle No Text style for the title.
textAlign TextAlign No Alignment for the title.
itemWidget Widget No Custom item widget or child for the pointed popup. No need to add iconWidget & title if you added this.

The important function to know. show - Function to show the custom pointed popup:

Attribute Type Default Required Description
rect Rect No The rect bound that the popup should appear around it.
widgetKey GlobalKey No The key to widget.
item CustomPointedPopupItem [class] No If you want the dynamic item widget or child inside the popup per action, you can add the item here.

The important enum to know. TriangleDirection - Enum to choose the direction of pointer or triangle shape:

Value Description
Straight This will create an pointer with straight upward.
Right This will create an pointer with slightly bended towards right.
FullRight This will create an pointer with fully bended towards right.
Left This will create an pointer with slightly bended towards left.
FullLeft This will create an pointer with fully bended towards left.

In order to create a custom pointed popup on the widget, there are several attributes that are supported by custom_pointed_popup:

Attribute Type Default Required Description
item CustomPointedPopupItem [class] Yes To create the item widget or child in pointed popup.
customHeight double Yes The custom height of the pointed popup.
displayBelowWidget bool false No If true always display the popup below the widget else automatically calculate the space and display the popup either up or below the widget.
triangleDirection TriangleDirection [enum] TraingleDirection.Straight No Determines the direction of pointer or triangle shape.
popupBorderRadius BorderRadius BorderRadius.circular(10.0) No Defines the border of the custom pointed popup.
popupElevation double 0 No The elevation of the pointed popup.
stateChanged Function(bool isShow) No This event function will fire immediately the the popup state changes.
backgroundColor Color Colors.red No Background color for pointed popup.
widthFractionWithRespectToDeviceWidth int 3 No Width ratio with respect to the device width.
onDismiss VoidCallBack No Callback function that fire when the custom pointed popup dismissed.
onClickWidget Function(CustomPointedPopupItem item) No Callback function that fire when the child of popup is clicked.
context BuildContext Yes Context where the popup to be shown.

##If you have any queries, email me to dipak.shrestha@eemc.edu.np

CREDITS

Contributors

Made with contributors-img.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。