Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add tutorial to a flutter app when we launch it for the first time

Tags:

flutter

Anyone knows how to add tutorial when the app is launched for the first time in flutter? Example is attached as an image.

Example

like image 503
Priyank Avatar asked Jul 10 '20 16:07

Priyank


People also ask

Can a beginner start with Flutter?

Flutter & Dart is a good course wherein you can learn both Dart and Flutter at once. Similarly, getting started with Flutter is a good beginner's course that you can take up for free.


2 Answers

You can use tutorial_coach_mark library,like:

import 'package:flutter/material.dart';
import 'package:tutorial_coach_mark/tutorial_coach_mark.dart';

void showTutorial() {
    TutorialCoachMark(
      context,
      targets: targets, // List<TargetFocus>
      colorShadow: Colors.red, // DEFAULT Colors.black
       // alignSkip: Alignment.bottomRight,
       // textSkip: "SKIP",
       // paddingFocus: 10,
      finish: (){
        print("finish");
      },
      clickTarget: (target){
        print(target);
      },
      clickSkip: (){
        print("skip");
      }
    )..show();
  }

To be able to use it for the first time you need the shared_preferences package:

SharedPreferences prefs = await SharedPreferences.getInstance();
var watchedIntro=prefs.getBool('watchedIntro')??false;
if(!watchedIntro)

and when the tutorial ended set watchedIntro to true:

await prefs.setBool('watchedIntro', true);
like image 121
Payam Asefi Avatar answered Oct 16 '22 14:10

Payam Asefi


You can try out this package, tutorial_coach_mark.

like image 27
Akora Ing. DKB Avatar answered Oct 16 '22 15:10

Akora Ing. DKB