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

feature_discovery 封面
插件详情v0.14.2

feature_discovery

一个 Flutter 包,用于实现 Material Design 特性发现功能,向新用户展示特定功能的说明。请参阅 https://tinyurl.com/FeatureDiscovery

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
2390
喜欢数
789
Pub 分数
140

安装插件

flutter pub add feature_discovery

插件介绍

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

一个 Flutter 包,实现 Material Design 特性发现功能,通过交互式教练标记引导新用户了解应用的关键功能。它会突出显示特定的 UI 元素,并提供描述性提示气泡以改善引导体验。旨在通过简洁现代的方式逐步解释功能,提升用户体验。兼容所有主要平台,包括移动、Web 和桌面端。非常适合向首次使用应用的用户介绍复杂工作流程或新功能。

适合场景

  • 引导新用户
  • 突出显示新应用功能
  • 引导用户通过复杂界面
  • 提高功能采用率
  • 向用户教育应用程序功能

主要特点

  • 符合 Material Design
  • 交互式教练标记
  • 跨平台支持
  • 可自定义的工具提示
  • 与现有小部件的无缝集成

适合对象

  • 新应用入门
  • 用户教育工具
  • 功能教程
  • 移动和桌面应用
  • 具有复杂工作流程的应用程序

使用建议

  • 需要仔细放置目标
  • 可能需要针对不同的布局进行定制
  • 不适合高级动画
  • 限于基本交互模式
  • 最适合初始用户体验

原始 README

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

feature_discovery

This Flutter package implements Feature Discovery following the Material Design guidelines.

With Feature Discovery, you can add context to any UI element, i.e. any Widget in your Flutter app.
Here is a small demo of the example app:

Installing

To use this package, follow the installing guide.

Usage

FeatureDiscovery

To be able to work with any of the global functions provided by the feature_discovery package, you will have to wrap your widget tree in a FeatureDiscovery widget.
There are many places where you can add FeatureDiscovery in your build tree, but the easiest to assure that it sits on top is to wrap your MaterialApp with it:

const FeatureDiscovery(
  child: MaterialApp(
   ...
  )
)
DescribedFeatureOverlay

For every UI element ( Widget ) that you want to describe using Feature Discovery, you will need to add a DescribedFeatureOverlay .
This widget takes all the parameters for the overlay that will be displayed during Feature Discovery and takes the Widget you want to display the overlay about as its child .

Feature ids

Every feature you describe should have a unique identifier, which is a String passed to the featureId parameter. You will also need to provide these ids when starting the discovery. And library will use this ids to save flag internally to indicate which feature is showed to user and completed by user. And if this feature is completed by user library will not show it again.

DescribedFeatureOverlay(
  featureId: 'add_item_feature_id', // Unique id that identifies this overlay.
  tapTarget: const Icon(Icons.add), // The widget that will be displayed as the tap target.
  title: Text('Add item'),
  description: Text('Tap the plus icon to add an item to your list.'),
  backgroundColor: Theme.of(context).primaryColor,
  targetColor: Colors.white,
  textColor: Colors.white,
  child: IconButton( // Your widget that is actually part of the UI.
    icon: cons Icon(Icons.add),
    onPressed: addItem,
  ),
);
Additional parameters
contentLocation

This is ContentLocation.trivial by default, however, the package cannot always determine the correct placement for the overlay. In those cases, you can provide either of these two:

  • ContentLocation.below : Text is displayed below the target.

  • ContentLocation.above : Text is displayed above the target.

onComplete
   onComplete: () async {
    // Executed when the tap target is tapped. The overlay will not close before
    // this function returns and after that, the next step will be opened.
    print('Target tapped.');
    // You can prevent completion by returning false.
    return true;
  },
onDismiss
  onDismiss: () async {
    // Called when the user taps outside of the overlay, trying to dismiss it.
    print('Overlay dismissed.');
    // You can prevent dismissal by returning false.
    return true;
  },
onOpen
  onOpen: () async {
    // This callback is called before the overlay is displayed.
    print('The overlay is about to be displayed.');
    // If you return false, the overlay will not be opened and the next step
    // will be attempted to open.
    return true;
  },
enablePulsingAnimation

This is set to true by default, but you can disable the pulsing animation about the tap target by setting this to false .

allowShowingDuplicate

If multiple DescribedFeatureOverlay s have the same featureId , they will interfere with each other during discovery and if you want to display multiple overlays at the same time, you will have to set allowShowingDuplicate to true for all of them.

barrierDismissible

This is set to true by default, but you can disable "dissmiss overlay on touch outside" by setting this to false .

overflowMode

This is OverflowMode.ignore by default, which will simply render the content you pass to title and description , even if it overflows the background area, i.e. the circle of the overlay. Alternatively, you can specify any of the following if you desire different behavior:

  • OverflowMode.clipContent will clip any content that is outside of the inner area (the background's circle).

  • OverflowMode.extendBackground will expand the background circle if necessary.

  • OverflowMode.wrapBackground will expand the background circle if necessary, but also shrink it if the content is smaller than the default background size.

FeatureDiscovery.discoverFeatures

When you want to showcase your features, you can call FeatureDiscovery.discoverFeatures with the applicable feature ids. The features will be displayed as steps in order if the user does not dismiss them.
By tapping the tap target, the user will be sent on to the next step and by tapping outside of the overlay, the user will dismiss all queued steps.

FeatureDiscovery.discoverFeatures(
  context,
  const <String>{ // Feature ids for every feature that you want to showcase in order.
    'add_item_feature_id',
  },
);

If you want to display Feature Discovery for a page right after it has been opened, you can use SchedulerBinding.addPostFrameCallback in the initState method of your StatefulWidget :

@override
void initState() {
  // ...
  SchedulerBinding.instance.addPostFrameCallback((Duration duration) {
    FeatureDiscovery.discoverFeatures(
      context,
      const <String>{ // Feature ids for every feature that you want to showcase in order.
        'add_item_feature_id',
      },
    ); 
  });
  super.initState();
}
FeatureDiscovery.clearPreferences

If you want to clear feature discovery flag use this command like that

FeatureDiscovery.clearPreferences(context, <String>{ 'add_item_feature_id', });
FeatureDiscovery.hasPreviouslyCompleted

If you want to findout feature discovery is Displayed or not ? use this command like that

FeatureDiscovery.hasPreviouslyCompleted (context,'desired_feature_id');
Other methods

You can view the API reference for FeatureDiscovery to find other useful methods for controlling the Feature Discovery process programmatically.

EnsureVisible

You can use the EnsureVisible widget to automatically scroll to widgets that are inside of scrollable viewports when they are described during Feature Discovery:

// You need to save an instance of a GlobalKey in order to call ensureVisible in onOpen.
GlobalKey<EnsureVisibleState> ensureVisibleGlobalKey = GlobalKey<EnsureVisibleState>();

// The widget in your build tree:
DescribedFeatureOverlay(
  featureId: 'list_item_feature_id',
  tapTarget: const Icon(Icons.cake),
  onOpen: () async {
    WidgetsBinding.instance.addPostFrameCallback((Duration duration) {
      ensureVisibleGlobalKey.currentState.ensureVisible();
      return true;
    });
  },
  title: Text('Cake'),
  description: Text('This is your reward for making it this far.'),
  child: EnsureVisible(
    key: ensureVisibleGlobalKey,
    child: const Icon(Icons.cake),
  ),
)

Notes

In DescribedFeatureOverlay , tapTarget , title , and description can take any widget, but it is recommended to use an Icon for the tap target and simple Text widgets for the title and description. The package takes care of styling these widgets and having these as Widget s allows you to pass Key s, Semantics , etc.

Contributing

If you want to start contributing to this package, it is recommended to refer to the contributing guide.

Gratitude

Thanks to mattcarroll for their Flutter challenge about Feature Discovery on Fluttery.

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目