1+ import 'dart:async' ;
12import 'dart:developer' ;
23
34import 'package:example/detailscreen.dart' ;
@@ -18,80 +19,89 @@ class MyApp extends StatelessWidget {
1819
1920 @override
2021 Widget build (BuildContext context) {
21- return MaterialApp (
22- title: 'Flutter ShowCase' ,
23- theme: ThemeData (
24- primaryColor: const Color (0xffEE5366 ),
25- ),
26- debugShowCheckedModeBanner: false ,
27- home: Scaffold (
28- body: ShowCaseWidget (
29- hideFloatingActionWidgetForShowcase: [_lastShowcaseWidget],
30- globalFloatingActionWidget: (showcaseContext) => FloatingActionWidget (
31- left: 16 ,
32- bottom: 16 ,
33- child: Padding (
34- padding: const EdgeInsets .all (16.0 ),
35- child: ElevatedButton (
36- onPressed: ShowCaseWidget .of (showcaseContext).dismiss,
37- style: ElevatedButton .styleFrom (
38- backgroundColor: const Color (0xffEE5366 ),
22+ return Padding (
23+ padding: const EdgeInsets .all (50 ),
24+ child: MaterialApp (
25+ title: 'Flutter ShowCase' ,
26+ theme: ThemeData (
27+ primaryColor: const Color (0xffEE5366 ),
28+ ),
29+ debugShowCheckedModeBanner: false ,
30+ home: Scaffold (
31+ floatingActionButton: SizedBox (
32+ height: 400 ,
33+ width: 400 ,
34+ child: ShowCaseWidget (
35+ hideFloatingActionWidgetForShowcase: [_lastShowcaseWidget],
36+ enableAutoScroll: true ,
37+ globalFloatingActionWidget: (showcaseContext) =>
38+ FloatingActionWidget (
39+ left: 16 ,
40+ bottom: 16 ,
41+ child: Padding (
42+ padding: const EdgeInsets .all (16.0 ),
43+ child: ElevatedButton (
44+ onPressed: ShowCaseWidget .of (showcaseContext).dismiss,
45+ style: ElevatedButton .styleFrom (
46+ backgroundColor: const Color (0xffEE5366 ),
47+ ),
48+ child: const Text (
49+ 'Skip' ,
50+ style: TextStyle (
51+ color: Colors .white,
52+ fontSize: 15 ,
53+ ),
54+ ),
55+ ),
3956 ),
40- child: const Text (
41- 'Skip' ,
42- style: TextStyle (
57+ ),
58+ onStart: (index, key) {
59+ log ('onStart: $index , $key ' );
60+ },
61+ onComplete: (index, key) {
62+ log ('onComplete: $index , $key ' );
63+ if (index == 4 ) {
64+ SystemChrome .setSystemUIOverlayStyle (
65+ SystemUiOverlayStyle .light.copyWith (
66+ statusBarIconBrightness: Brightness .dark,
67+ statusBarColor: Colors .white,
68+ ),
69+ );
70+ }
71+ },
72+ blurValue: 1 ,
73+ autoPlayDelay: const Duration (seconds: 3 ),
74+ builder: (context) => const MailPage (),
75+ globalTooltipActionConfig: const TooltipActionConfig (
76+ position: TooltipActionPosition .inside,
77+ alignment: MainAxisAlignment .spaceBetween,
78+ actionGap: 20 ,
79+ ),
80+ globalTooltipActions: [
81+ // Here we don't need previous action for the first showcase widget
82+ // so we hide this action for the first showcase widget
83+ TooltipActionButton (
84+ type: TooltipDefaultActionType .previous,
85+ textStyle: const TextStyle (
4386 color: Colors .white,
44- fontSize: 15 ,
4587 ),
88+ hideActionWidgetForShowcase: [_firstShowcaseWidget],
4689 ),
47- ),
48- ),
49- ),
50- onStart: (index, key) {
51- log ('onStart: $index , $key ' );
52- },
53- onComplete: (index, key) {
54- log ('onComplete: $index , $key ' );
55- if (index == 4 ) {
56- SystemChrome .setSystemUIOverlayStyle (
57- SystemUiOverlayStyle .light.copyWith (
58- statusBarIconBrightness: Brightness .dark,
59- statusBarColor: Colors .white,
90+ // Here we don't need next action for the last showcase widget so we
91+ // hide this action for the last showcase widget
92+ TooltipActionButton (
93+ type: TooltipDefaultActionType .next,
94+ textStyle: const TextStyle (
95+ color: Colors .white,
96+ ),
97+ hideActionWidgetForShowcase: [_lastShowcaseWidget],
6098 ),
61- );
62- }
63- },
64- blurValue: 1 ,
65- autoPlayDelay: const Duration (seconds: 3 ),
66- builder: (context) => const MailPage (),
67- globalTooltipActionConfig: const TooltipActionConfig (
68- position: TooltipActionPosition .inside,
69- alignment: MainAxisAlignment .spaceBetween,
70- actionGap: 20 ,
71- ),
72- globalTooltipActions: [
73- // Here we don't need previous action for the first showcase widget
74- // so we hide this action for the first showcase widget
75- TooltipActionButton (
76- type: TooltipDefaultActionType .previous,
77- textStyle: const TextStyle (
78- color: Colors .white,
79- ),
80- hideActionWidgetForShowcase: [_firstShowcaseWidget],
81- ),
82- // Here we don't need next action for the last showcase widget so we
83- // hide this action for the last showcase widget
84- TooltipActionButton (
85- type: TooltipDefaultActionType .next,
86- textStyle: const TextStyle (
87- color: Colors .white,
88- ),
89- hideActionWidgetForShowcase: [_lastShowcaseWidget],
99+ ],
100+ onDismiss: (key) {
101+ debugPrint ('Dismissed at $key ' );
102+ },
90103 ),
91- ],
92- onDismiss: (key) {
93- debugPrint ('Dismissed at $key ' );
94- },
104+ ),
95105 ),
96106 ),
97107 );
@@ -118,8 +128,11 @@ class _MailPageState extends State<MailPage> {
118128 super .initState ();
119129 //Start showcase view after current widget frames are drawn.
120130 WidgetsBinding .instance.addPostFrameCallback (
121- (_) => ShowCaseWidget .of (context).startShowCase (
122- [_firstShowcaseWidget, _two, _three, _four, _lastShowcaseWidget]),
131+ (_) async {
132+ await Future .delayed (Duration (seconds: 5 ));
133+ ShowCaseWidget .of (context).startShowCase (
134+ [_firstShowcaseWidget, _two, _three, _four, _lastShowcaseWidget]);
135+ },
123136 );
124137 mails = [
125138 Mail (
@@ -373,7 +386,7 @@ class _MailPageState extends State<MailPage> {
373386 controller: scrollController,
374387 physics: const BouncingScrollPhysics (),
375388 itemBuilder: (context, index) {
376- if (index == 0 ) {
389+ if (index == 4 ) {
377390 return showcaseMailTile (_three, true , context, mails.first);
378391 }
379392 return MailTile (
@@ -386,7 +399,7 @@ class _MailPageState extends State<MailPage> {
386399 ),
387400 ),
388401 floatingActionButton: Showcase (
389- key: _lastShowcaseWidget ,
402+ key: _firstShowcaseWidget ,
390403 title: 'Compose Mail' ,
391404 description: 'Click here to compose mail' ,
392405 targetBorderRadius: const BorderRadius .all (Radius .circular (16 )),
0 commit comments