helps tutorial coach mark
helps guide that helps you to present your app and its features in a beautiful, simple and customizable way.
tutorialcoachmark
example 1 | example 2 |
---|---|
usage
to use this plugin, add tutorial_coach_mark
as a dependency in your pubspec.yaml file.
example
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();
}
warn: make sure your view has been rendered before calling ‘show’ so the lib can find the position of the widget on the screen.
creating targets (targetfocus)
targetfocus is the class that represents the widget that will be focused and configure what will be displayed after you focus it.
attributes:
attribute | type | description |
---|---|---|
identify |
dynamic | free for identification use |
keytarget |
globalkey | globalkey widget that wants to be focused |
targetposition |
targetposition | if you do not want to use globalkey, you can create a targetposition to determine where to focus |
contents |
contenttarget[] | content list you want to display after focusing widget |
creating contents (contenttarget)
contenttarget is the class responsible for determining what should be displayed and how it will appear after focusing on the widget.
attributes:
attribute | type | description |
---|---|---|
align |
aligncontent | with this attribute you determine in which region to display the content in relation to the focused widget (top,bottom,left,right) |
child |
widget | content you want to be displayed |
example complete
import 'package:flutter/material.dart';
import 'package:tutorial_coach_mark/tutorial_coach_mark.dart';
list<targetfocus> targets = list();
@override
void initstate() {
targets.add(
targetfocus(
identify: "target 1",
keytarget: keybutton,
contents: [
contenttarget(
align: aligncontent.bottom,
child: container(
child:column(
mainaxissize: mainaxissize.min,
crossaxisalignment: crossaxisalignment.start,
children: <widget>[
text(
"titulo lorem ipsum",
style: textstyle(
fontweight: fontweight.bold,
color: colors.white,
fontsize: 20.0
),
),
padding(
padding: const edgeinsets.only(top: 10.0),
child: text("lorem ipsum dolor sit amet, consectetur adipiscing elit. proin pulvinar tortor eget maximus iaculis.",
style: textstyle(
color: colors.white
),),
)
],
),
)
)
]
)
);
targets.add(
targetfocus(
identify: "target 2",
keytarget: keybutton4,
contents: [
contenttarget(
align: aligncontent.left,
child: container(
child: column(
mainaxissize: mainaxissize.min,
crossaxisalignment: crossaxisalignment.start,
children: <widget>[
text(
"multiples content",
style: textstyle(
fontweight: fontweight.bold,
color: colors.white,
fontsize: 20.0
),
),
padding(
padding: const edgeinsets.only(top: 10.0),
child: text("lorem ipsum dolor sit amet, consectetur adipiscing elit. proin pulvinar tortor eget maximus iaculis.",
style: textstyle(
color: colors.white
),),
)
],
),
)
),
contenttarget(
align: aligncontent.top,
child: container(
child: column(
mainaxissize: mainaxissize.min,
crossaxisalignment: crossaxisalignment.start,
children: <widget>[
text(
"multiples content",
style: textstyle(
fontweight: fontweight.bold,
color: colors.white,
fontsize: 20.0
),
),
padding(
padding: const edgeinsets.only(top: 10.0),
child: text("lorem ipsum dolor sit amet, consectetur adipiscing elit. proin pulvinar tortor eget maximus iaculis.",
style: textstyle(
color: colors.white
),),
)
],
),
)
)
]
)
);
targets.add(
targetfocus(
identify: "target 3",
keytarget: keybutton5,
contents: [
contenttarget(
align: aligncontent.right,
child: container(
child: column(
mainaxissize: mainaxissize.min,
crossaxisalignment: crossaxisalignment.start,
children: <widget>[
text(
"title lorem ipsum",
style: textstyle(
fontweight: fontweight.bold,
color: colors.white,
fontsize: 20.0
),
),
padding(
padding: const edgeinsets.only(top: 10.0),
child: text("lorem ipsum dolor sit amet, consectetur adipiscing elit. proin pulvinar tortor eget maximus iaculis.",
style: textstyle(
color: colors.white
),),
)
],
),
)
)
]
)
);
}
void showtutorial() {
tutorialcoachmark(
context,
targets: targets, // list<targetfocus>
colorshadow: colors.red, // default colors.black
// alignskip: alignment.bottomright,
// textskip: "skip",
// paddingfocus: 10,
// opacityshadow: 0.8,
finish: (){
print("finish");
},
clicktarget: (target){
print(target);
},
clickskip: (){
print("skip");
}
)..show();
}
Comments are closed.