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

overlay_tooltip 封面
插件详情v0.2.4

overlay_tooltip

用于引导的覆盖工具提示处理程序

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
2800
喜欢数
240
Pub 分数
140

安装插件

flutter pub add overlay_tooltip

插件介绍

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

overlay_tooltip 是一个专为创建引导体验的覆盖工具提示而设计的 Flutter 包。它使开发者能够通过在特定 UI 元素上显示上下文相关且带有动画效果的工具提示,引导用户了解应用功能。适用于功能发现和用户引导流程,支持 Android、iOS、Web、macOS、Windows 和 Linux 多个平台。该包可无缝集成到现有的 Flutter 应用中,并提供可自定义的位置、样式和交互处理。在教程或引导演示中,当视觉提示至关重要时尤为有用。

适合场景

  • 引导新用户
  • 引导用户了解应用功能
  • 在教程中突出显示UI元素
  • 通过互动提示提升用户参与度
  • 创建引导式产品导览

主要特点

  • 基于叠加层的提示框渲染
  • 可自定义的提示框外观
  • 动画入场和出场过渡
  • 对多个平台的支持
  • 与现有 Flutter 小部件轻松集成
  • 可配置的目标元素对齐

适合对象

  • 应用入门屏幕
  • 用户教育工具
  • 功能演示
  • 移动和网络应用
  • 寻求轻量级教练标记的开发者

使用建议

  • 需要仔细定位以避免内容重叠
  • 可能需要额外的逻辑来处理复杂的导航流程
  • 有限的内置动画预设
  • 最适合简单的线性引导流程
  • 不适合持久的用户界面引导

原始 README

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

Overlay_tooltip

A Package that helps display tooltips for onboarding certain features in your app.

Motivation

Due to the non-flexibility of some other tooltips packages, Overlay tooltip is designed to give you control over the nature of your tooltips widget, overlay colors, when to start/dismiss tooltips and moving between previous/next tooltips.

Usage

To use this package :

  • add the dependency to your pubspec.yaml file.
dependencies:
  flutter:
    sdk: flutter
  overlay_tooltip:
Setup

1. First of all, create a TooltipController. This should be created for every screen where tooltip is to be shown as it handles operations like starting, dismissing, moving to next/previous and pausing tooltips etc.

final TooltipController _controller = TooltipController();

This also provides ability to add an onDone method that runs when the tooltips for that controller is completed.

OverlayTooltipScaffold(
    overlayColor: Colors.red.withOpacity(.4),
    tooltipAnimationCurve: Curves.linear,
    tooltipAnimationDuration: const Duration(milliseconds: 1000),
    controller: controller,
    // if you need to have control over the background overlay for gestures
    preferredOverlay: GestureDetector(
      onTap: () {
        _controller.dismiss();
        //move the overlay forward or backwards, or dismiss the overlay
      },
      child: Container(
        height: double.infinity,
        width: double.infinity,
        color: Colors.blue.withOpacity(.2),
      ),
    ),
    child: Scaffold(),
  );

3. Wrap individual widgets to be displayed with an OverlayTooltipItem widget.

 OverlayTooltipItem(
    displayIndex: 0,
    tooltip: (controller) {
      return Padding(
        padding: const EdgeInsets.only(left: 15),
        child: MTooltip(title: 'Some Text Tile', controller: controller),
      );
    },
    child: _sampleWidget(),
  );

This widget can be instantiated with the following parameters:

  • ignorePointer (optional) - true by default. Controls whether the wrapped widget is clickable or not.

  • displayIndex - This ensures the order in which the tooltips are displayed

  • tooltip - This is a widget function that exposes the controller and can be used to create a custom widget to display as the tooltip.

  • tooltipVerticalPosition - The vertical positioning of the tooltip in relation to the main child widget, defaults to TooltipVerticalPosition.BOTTOM. Other options are TooltipVerticalPosition.TOP

  • tooltipHorizontalPosition - The horizontal positioning of the tooltip, defaults to TooltipHorizontalPosition.WITH_WIDGET and this aligns the tooltip with the child widget. Other options are TooltipHorizontalPosition.LEFT. TooltipHorizontalPosition.RIGHT or TooltipHorizontalPosition.CENTER


Displaying Tooltips

This can be done in three ways;

  • You can get access to the controller from sub widgets in the same context.

    OverlayTooltipScaffold.of(context)?.controller;
    
  • Manually start the tooltips in any function by calling the start method, or pass a displayIndex to the start method indicating where to begin.

    _controller.start(); // starts tooltip display from the beginning
    _controller.start(1);// starts tooltip display from displayIndex of 1
    
  • Or Use the startWhen method to start the tooltips display automatically whenever a condition is met. This takes in a Future bool function with an initializedWidgetLength parameter denoting the length of tooltips widget that have been initialized.

    _controller.startWhen( (initializedWidgetLength) async {
           //await any function and return a bool value when done.
         await Future.delayed(const Duration(milliseconds: 500));
         return initializedWidgetLength == 2 && !done;
       });
    
  • Or Add the startWhen parameter to the OverlayTooltipScaffold to also start the tooltips display automatically when a condition is met.

    return OverlayTooltipScaffold(
        ...
         startWhen: (initializedWidgetLength) async{
            await Future.delayed(const Duration(milliseconds: 500));
            return initializedWidgetLength == 2 && !done;
          },
          ...
          child: Scaffold(
             ...
          )
        );
    

Other methods on the TooltipController
Method Type Description
dismiss() void Dismiss overlay
next() void Moving to next tooltip
previous() void Moving to previous tooltip
pause() void Pause tooltip display without triggering onDone method
nextPlayIndex int Get index of current tooltip
playWidgetLength int Get total length of tooltips to be displayed

Check example project for usage and/or clarifications.

Getting Started

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。