Deuque / overlay_tooltip

An overlay tooltip handler for onboarding
BSD 3-Clause "New" or "Revised" License
16 stars 26 forks source link

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 :

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:


Displaying Tooltips

This can be done in three ways;


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.