tutorial_coach_mark 1.0.3 tutorial_coach_mark: ^1.0.3 copied to clipboard
Guide that helps you to present your app and its features in a beautiful, simple and customizable way.
import 'package:flutter/material.dart';
import 'package:tutorial_coach_mark/tutorial_coach_mark.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'TutorialCoachMark Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
late TutorialCoachMark tutorialCoachMark;
List<TargetFocus> targets = <TargetFocus>[];
GlobalKey keyButton = GlobalKey();
GlobalKey keyButton1 = GlobalKey();
GlobalKey keyButton2 = GlobalKey();
GlobalKey keyButton3 = GlobalKey();
GlobalKey keyButton4 = GlobalKey();
GlobalKey keyButton5 = GlobalKey();
@override
void initState() {
initTargets();
showTutorial();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
actions: <Widget>[
IconButton(
// key: keyButton1,
icon: Icon(Icons.add),
onPressed: () {},
),
PopupMenuButton(
key: keyButton1,
icon: Icon(Icons.view_list, color: Colors.white),
itemBuilder: (context) => [
PopupMenuItem(
child: Text("Is this"),
),
PopupMenuItem(
child: Text("What"),
),
PopupMenuItem(
child: Text("You Want?"),
),
],
)
],
),
body: Container(
color: Colors.white,
child: Stack(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 100.0),
child: Align(
alignment: Alignment.topCenter,
child: Container(
key: keyButton,
color: Colors.blue,
height: 100,
width: MediaQuery.of(context).size.width - 50,
child: Align(
alignment: Alignment.center,
child: ElevatedButton(
child: Icon(Icons.remove_red_eye),
onPressed: () {
showTutorial();
},
),
),
),
),
),
Align(
alignment: Alignment.center,
child: SizedBox(
width: 50,
height: 50,
child: ElevatedButton(
key: keyButton2,
onPressed: () {},
child: Container(),
),
),
),
Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: const EdgeInsets.all(50.0),
child: SizedBox(
width: 50,
height: 50,
child: ElevatedButton(
key: keyButton3,
onPressed: () {},
child: Container(),
),
),
),
),
Align(
alignment: Alignment.centerRight,
child: Padding(
padding: const EdgeInsets.all(50.0),
child: SizedBox(
width: 50,
height: 50,
child: ElevatedButton(
key: keyButton4,
onPressed: () {},
child: Container(),
),
),
),
),
Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.all(50.0),
child: SizedBox(
width: 50,
height: 50,
child: ElevatedButton(
key: keyButton5,
onPressed: () {},
child: Container(),
),
),
),
)
],
),
),
);
}
void initTargets() {
targets.add(
TargetFocus(
identify: "Target 0",
keyTarget: keyButton1,
contents: [
TargetContent(
align: ContentAlign.bottom,
builder: (context, controller) {
return 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 1",
keyTarget: keyButton,
color: Colors.purple,
contents: [
TargetContent(
align: ContentAlign.bottom,
builder: (context, controller) {
return 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),
),
),
ElevatedButton(
onPressed: () {
controller.previous();
},
child: Icon(Icons.chevron_left),
),
],
),
);
},
)
],
shape: ShapeLightFocus.RRect,
radius: 5,
),
);
targets.add(
TargetFocus(
identify: "Target 2",
keyTarget: keyButton4,
contents: [
TargetContent(
align: ContentAlign.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),
),
)
],
),
),
),
TargetContent(
align: ContentAlign.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),
),
)
],
),
))
],
shape: ShapeLightFocus.RRect,
),
);
targets.add(TargetFocus(
identify: "Target 3",
keyTarget: keyButton5,
contents: [
TargetContent(
align: ContentAlign.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),
),
)
],
),
))
],
shape: ShapeLightFocus.RRect,
));
targets.add(TargetFocus(
identify: "Target 4",
keyTarget: keyButton3,
contents: [
TargetContent(
align: ContentAlign.top,
child: Container(
child: Column(
children: <Widget>[
InkWell(
onTap: () {
tutorialCoachMark.previous();
},
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Image.network(
"https://juststickers.in/wp-content/uploads/2019/01/flutter.png",
height: 200,
),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 20.0),
child: Text(
"Image Load network",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20.0),
),
),
Text(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin pulvinar tortor eget maximus iaculis.",
style: TextStyle(color: Colors.white),
),
],
),
),
),
],
shape: ShapeLightFocus.Circle,
));
targets.add(TargetFocus(
identify: "Target 5",
keyTarget: keyButton2,
contents: [
TargetContent(
align: ContentAlign.top,
child: Container(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(bottom: 20.0),
child: Text(
"Multiples contents",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20.0),
),
),
Text(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin pulvinar tortor eget maximus iaculis.",
style: TextStyle(color: Colors.white),
),
],
),
),
),
TargetContent(
align: ContentAlign.bottom,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(bottom: 20.0),
child: Text(
"Multiples contents",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20.0),
),
),
Container(
child: Text(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin pulvinar tortor eget maximus iaculis.",
style: TextStyle(color: Colors.white),
),
),
],
))
],
shape: ShapeLightFocus.Circle,
));
}
void showTutorial() {
tutorialCoachMark = TutorialCoachMark(
context,
targets: targets,
colorShadow: Colors.red,
textSkip: "SKIP",
paddingFocus: 10,
opacityShadow: 0.8,
onFinish: () {
print("finish");
},
onClickTarget: (target) {
print('onClickTarget: $target');
},
onSkip: () {
print("skip");
},
onClickOverlay: (target) {
print('onClickOverlay: $target');
},
)..show();
}
}