Skip to content

Commit 8a55dac

Browse files
committed
🩹Updated: Updated name of parameter and also added support for the floatingAction Widget for the default showcase widget
1 parent 7915a3b commit 8a55dac

File tree

3 files changed

+63
-11
lines changed

3 files changed

+63
-11
lines changed

example/lib/main.dart

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,37 @@ class _MailPageState extends State<MailPage> {
221221
"Tap to see profile which contains user's name, profile picture, mobile number and country",
222222
tooltipBackgroundColor: Theme.of(context).primaryColor,
223223
textColor: Colors.white,
224+
floatingActionWidget: Align(
225+
alignment: Alignment.bottomLeft,
226+
child: Padding(
227+
padding: const EdgeInsets.all(16.0),
228+
child: ElevatedButton(
229+
style: ButtonStyle(
230+
backgroundColor: MaterialStateProperty.all<Color>(
231+
Theme.of(context).primaryColor),
232+
shape: MaterialStateProperty.all<
233+
RoundedRectangleBorder>(
234+
RoundedRectangleBorder(
235+
borderRadius: BorderRadius.circular(18.0),
236+
side: BorderSide(
237+
color: Theme.of(context).primaryColor,
238+
width: 2.0,
239+
),
240+
),
241+
),
242+
),
243+
child: const Text(
244+
'Skip Showcase',
245+
style: TextStyle(
246+
color: Colors.white,
247+
fontSize: 15,
248+
),
249+
),
250+
onPressed: () =>
251+
ShowCaseWidget.of(context).dismiss(),
252+
),
253+
),
254+
),
224255
targetShapeBorder: const CircleBorder(),
225256
child: Container(
226257
padding: const EdgeInsets.all(5),
@@ -416,8 +447,9 @@ class MailTile extends StatelessWidget {
416447
targetBorderRadius: const BorderRadius.all(
417448
Radius.circular(150),
418449
),
419-
staticContainer: Column(
450+
floatingActionWidget: Column(
420451
mainAxisAlignment: MainAxisAlignment.end,
452+
crossAxisAlignment: CrossAxisAlignment.start,
421453
children: [
422454
Padding(
423455
padding: const EdgeInsets.all(16.0),
@@ -436,7 +468,13 @@ class MailTile extends StatelessWidget {
436468
),
437469
),
438470
),
439-
child: const Text('Skip Showcase'),
471+
child: const Text(
472+
'Skip Showcase',
473+
style: TextStyle(
474+
color: Colors.white,
475+
fontSize: 15,
476+
),
477+
),
440478
onPressed: () =>
441479
ShowCaseWidget.of(context).dismiss(),
442480
),

lib/src/showcase.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ class Showcase extends StatefulWidget {
9898
/// Custom tooltip widget when [Showcase.withWidget] is used.
9999
final Widget? container;
100100

101-
/// Custom static tooltip widget when [Showcase.withWidget] is used.
102-
final Widget? staticContainer;
101+
/// Custom static floating action widget to show a static widget anywhere
102+
/// on the screen
103+
final Widget? floatingActionWidget;
103104

104105
/// Defines background color for tooltip widget.
105106
///
@@ -308,10 +309,10 @@ class Showcase extends StatefulWidget {
308309
this.disableBarrierInteraction = false,
309310
this.toolTipSlideEndDistance = 7,
310311
this.toolTipMargin = 14,
312+
this.floatingActionWidget,
311313
}) : height = null,
312314
width = null,
313315
container = null,
314-
staticContainer = null,
315316
assert(overlayOpacity >= 0.0 && overlayOpacity <= 1.0,
316317
"overlay opacity must be between 0 and 1."),
317318
assert(onTargetClick == null || disposeOnTap != null,
@@ -327,7 +328,7 @@ class Showcase extends StatefulWidget {
327328
required this.width,
328329
required this.container,
329330
required this.child,
330-
this.staticContainer,
331+
this.floatingActionWidget,
331332
this.targetShapeBorder = const RoundedRectangleBorder(
332333
borderRadius: BorderRadius.all(
333334
Radius.circular(8),
@@ -622,7 +623,7 @@ class _ShowcaseState extends State<Showcase> {
622623
titleTextStyle: widget.titleTextStyle,
623624
descTextStyle: widget.descTextStyle,
624625
container: widget.container,
625-
staticContainer: widget.staticContainer,
626+
floatingActionWidget: widget.floatingActionWidget,
626627
tooltipBackgroundColor: widget.tooltipBackgroundColor,
627628
textColor: widget.textColor,
628629
showArrow: widget.showArrow,

lib/src/tooltip_widget.dart

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ToolTipWidget extends StatefulWidget {
4040
final TextStyle? titleTextStyle;
4141
final TextStyle? descTextStyle;
4242
final Widget? container;
43-
final Widget? staticContainer;
43+
final Widget? floatingActionWidget;
4444
final Color? tooltipBackgroundColor;
4545
final Color? textColor;
4646
final bool showArrow;
@@ -75,7 +75,7 @@ class ToolTipWidget extends StatefulWidget {
7575
required this.titleTextStyle,
7676
required this.descTextStyle,
7777
required this.container,
78-
required this.staticContainer,
78+
required this.floatingActionWidget,
7979
required this.tooltipBackgroundColor,
8080
required this.textColor,
8181
required this.showArrow,
@@ -367,7 +367,7 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
367367
}
368368

369369
if (widget.container == null) {
370-
return Positioned(
370+
final defaultToolTipWidget = Positioned(
371371
top: contentY,
372372
left: _getLeft(),
373373
right: _getRight(),
@@ -493,9 +493,22 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
493493
),
494494
),
495495
);
496+
497+
if (widget.floatingActionWidget != null) {
498+
return Stack(
499+
fit: StackFit.expand,
500+
children: [
501+
defaultToolTipWidget,
502+
widget.floatingActionWidget!,
503+
],
504+
);
505+
} else {
506+
return defaultToolTipWidget;
507+
}
496508
}
497509

498510
return Stack(
511+
fit: StackFit.expand,
499512
children: <Widget>[
500513
Positioned(
501514
left: _getSpace(),
@@ -532,7 +545,7 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
532545
),
533546
),
534547
),
535-
if (widget.staticContainer != null) ...[widget.staticContainer!],
548+
if (widget.floatingActionWidget != null) widget.floatingActionWidget!,
536549
],
537550
);
538551
}

0 commit comments

Comments
 (0)