搜尋套件、儲存庫與 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.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。