flutter_introduction_tooltip 0.0.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new75

Flutter Introduction Tooltip

A new Flutter plugin to show introduction tooltip for first timer user of the app.

It should support both Android and iOS since it's pure written in Dart.

Getting Started

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

Screenshots

<img src="https://raw.githubusercontent.com/blackmenthor/flutter-introduction-tooltip/master/Screenshot_1.png" width= "200" height="350"> <img src="https://raw.githubusercontent.com/blackmenthor/flutter-introduction-tooltip/master/Screenshot_2.png" width= "200" height="350">

Installation and Usage

To install this package, you need to add flutter_introduction_tooltip (0.1.0 or higher) to the dependencies list of the pubspec.yaml file as follow:

dependencies:
  flutter:
    sdk: flutter

  flutter_introduction_tooltip: ^0.1.0

Then run command flutter packages get on the console.

How to use

Add the import to flutter_introduction_tooltip/flutter_introduction_tooltip.dart

Create a global key and attach to the widget you preferred.

import 'package:flutter_introduction_tooltip/flutter_introduction_tooltip.dart

GlobalKey globalKey = GlobalKey();
bool isShowing = false;

@override
  Widget build(BuildContext context) {
    showTutorial(context);
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Builder(
            builder: (BuildContext context) {
              showTutorial(context);
              return Stack(
                children: <Widget> [
                  Container(
                    width: MediaQuery
                        .of(context)
                        .size
                        .width,
                    alignment: Alignment.bottomCenter,
                    child: Container(
                      color: Colors.blue,
                      key: globalKey,
                      child: Text(
                        'Running on: $_platformVersion\n',
                      ),
                    ),
                  ),
                ],
              );
            }
        ),
      ),
    );

void showTutorial(BuildContext context) async {
    if (!isShowing) {
      new Timer(Duration(milliseconds: 100), () async {
        try {
          FlutterIntroductionTooltip.showTopTutorialOnWidget(
              context,
              globalKey,
              Colors.blue,
                  () => popAndNextTutorial(context),
              "MAMA",
              "MAMA IS A LOREM IPSUM",
              "ALRIGHT");
          print("SHOWING");
          setState(() {
            isShowing = true;
          });
        } catch (e) {
          print("ERROR $e");
        }
      });
    }
  }

If you want the dialog to be on top of the widget, use showTopTutorialOnWidget, If you want the dialog to be on bottom of the widget, use showBottomTutorialOnWidget

The reason i use delay for the execution is because i run the function on the build method, and the build hasn't done yet so i can't draw the tutorial right there, so i delayed it.

Other alternative for doing this is to use library like https://pub.dartlang.org/packages/after_layout

Call Parameters

MANDATORY

  • BuildContext (current context)
  • GlobalKey (globalkey attached to your widget)
  • Color primaryColor (primary color used for the button and circle pointer)
  • VoidCallback positiveCallback (positive callback used when the positive button is clicked)
  • String title (title of the dialog)
  • String subtitlte (subtitle of the dialog)
  • String positiveBtn (title of the positive btn)

OPTIONAL

  • LineHorizontalPosition lineHorizontalPosition (where you want the line to be, the options is Left, Center, and Right)
  • Widget childBoxWidget (the custom widget if you don't want to use the dialog i provided)
  • bool showLine *defaults to true (whether you want to show the line on top of the dialog or not)
  • double lineHeight *defaults to 7.0 (the height of the line you desired)
  • Widget circleWidget (the circle widget at the end of the line if you want to customize it)
  • bool barrierDismissable *defaults to true (whether you want the background click will dismiss it or not)

Contributors

Contributions

Any contributions is very welcomed in this package, just fork this repository to your own github account and create a pull request with the changes description.

Contact

If you need to ask or discuss about anything, just email me at anggadwiarifandi96@gmail.com

*TODO:

  • Make function that can shows tooltip in right or left of the widget

0.0.1

Implemented functions:

  • Show tooltip as a dialog on top or bottom of a widget
  • Make inside widget customizable
  • Make circle widget customizable
  • Make barrierdismissable customizable
  • Make lineHeight customizable
  • Make showline customizable,

0.0.2

  • Generate dartdoc
  • add more padding so the line and widget intersect

0.0.3

  • Fix bugs so got higher score

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_introduction_tooltip/flutter_introduction_tooltip.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp>{
  String _platformVersion = 'Unknown';
  GlobalKey globalKey = GlobalKey();
  GlobalKey globalKey2 = GlobalKey();
  bool isShowing = false;
  bool isShowing2 = false;

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  void popAndNextTutorial(BuildContext context) {
    Navigator.pop(context);
    showTutorial2(context);
  }

  void showTutorial(BuildContext context) async {
    if (!isShowing) {
      new Timer(Duration(milliseconds: 100), () async {
        try {
          FlutterIntroductionTooltip.showTopTutorialOnWidget(
              context,
              globalKey,
              Colors.blue,
                  () => popAndNextTutorial(context),
              "MAMA",
              "MAMA IS A LOREM IPSUM",
              "ALRIGHT");
          print("SHOWING");
          setState(() {
            isShowing = true;
          });
        } catch (e) {
          print("ERROR $e");
        }
      });
    }
  }

  void showTutorial2(BuildContext context) async {
    if (!isShowing2) {
      new Timer(Duration(milliseconds: 100), () async {
        try {
          FlutterIntroductionTooltip.showBottomTutorialOnWidget(
              context,
              globalKey2,
              Colors.blue,
                  () => Navigator.pop(context),
              "MAMA",
              "MAMA IS A LOREM IPSUM",
              "ALRIGHT");
          print("SHOWING");
          setState(() {
            isShowing2 = true;
          });
        } catch (e) {
          print("ERROR $e");
        }
      });
    }
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await FlutterIntroductionTooltip.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    showTutorial(context);
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Builder(
            builder: (BuildContext context) {
              showTutorial(context);
              return Stack(
                children: <Widget> [
                  Container(
                    width: MediaQuery
                        .of(context)
                        .size
                        .width,
                    alignment: Alignment.bottomCenter,
                    child: Container(
                      color: Colors.blue,
                      key: globalKey,
                      child: Text(
                        'Running on: $_platformVersion\n',
                      ),
                    ),
                  ),
                  Container(
                    width: MediaQuery
                        .of(context)
                        .size
                        .width,
                    alignment: Alignment.topCenter,
                    child: Container(
                      color: Colors.blue,
                      key: globalKey2,
                      child: Text(
                        'Running on: $_platformVersion\n',
                      ),
                    ),
                  )
                ],
              );
            }
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_introduction_tooltip: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_introduction_tooltip/flutter_introduction_tooltip.dart';
  
Version Uploaded Documentation Archive
0.0.3 Oct 22, 2018 Go to the documentation of flutter_introduction_tooltip 0.0.3 Download flutter_introduction_tooltip 0.0.3 archive
0.0.2 Oct 22, 2018 Go to the documentation of flutter_introduction_tooltip 0.0.2 Download flutter_introduction_tooltip 0.0.2 archive
0.0.1 Oct 22, 2018 Go to the documentation of flutter_introduction_tooltip 0.0.1 Download flutter_introduction_tooltip 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
54
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
75
Learn more about scoring.

We analyzed this package on Nov 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.6
  • Flutter: 0.11.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8