Skip to content

Commit 643eeb8

Browse files
aditya-cssSahil-Simform
authored andcommitted
refactor: 🔨 Refactor considering Dart 3 support
1 parent e5d5715 commit 643eeb8

30 files changed

+745
-1135
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## [4.1.0] - (UnRelease)
1+
## [5.0.0] - (UnRelease)
22
- Feature [#500](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/500) -
33
Added `onDismiss` callback in `ShowCaseWidget` which will trigger whenever `onDismiss` method is
44
called.
@@ -35,6 +35,8 @@
3535
`toolTipMargin` support for `Showcase.withWidget`
3636
- Feature [#520](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/520) - Added
3737
`targetTooltipGap` to manage space between tooltip and target widget
38+
- Improvement [#530](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/pull/530) -
39+
Upgraded minimum dart sdk version to 3.0.0 and utilised Dart 3 features accordingly.
3840

3941
## [4.0.1]
4042
- Fixed [#493](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/493) - ShowCase.withWidget not showing issue

lib/showcaseview.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ export 'src/models/tooltip_action_config.dart';
2828
export 'src/showcase/showcase.dart';
2929
export 'src/showcase/showcase_view.dart';
3030
export 'src/showcase_widget.dart';
31-
export 'src/utils/enum.dart';
31+
export 'src/utils/enum.dart' hide ShowcaseProgressType, TooltipLayoutSlot;
3232
export 'src/widget/floating_action_widget.dart';
3333
export 'src/widget/tooltip_action_button_widget.dart';

lib/src/models/showcase_scope.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import '../showcase/showcase_controller.dart';
2525
import '../showcase/showcase_view.dart';
2626

2727
class ShowcaseScope {
28-
/// A container class that manages showcase views within a specific named scope.
28+
/// A container class that manages showcase views within a specific named
29+
/// scope.
2930
///
3031
/// This class is responsible for:
3132
/// - Maintain a reference to a named scope and its associated [ShowcaseView].

lib/src/models/tooltip_action_button.dart

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -24,48 +24,39 @@ import 'package:flutter/material.dart';
2424
import '../../showcaseview.dart';
2525

2626
class TooltipActionButton {
27-
/// A configuration for a tooltip action button or Provide a custom tooltip
28-
/// action.
27+
/// A class that defines interactive action buttons within showcase tooltips.
2928
///
30-
/// This class allows you to define predefined actions like "Next,"
31-
/// "Previous," and "Close," or specify a custom action widget.
29+
/// Provides a way to add interactive buttons to tooltips in the showcase
30+
/// view. These buttons can perform standard navigation actions also
31+
/// supports custom actions through callback functions and fully custom
32+
/// button widgets.
3233
///
33-
/// **Required arguments:**
34+
/// There are two ways to create tooltip action buttons:
35+
/// 1. Using the default constructor for standard buttons with predefined
36+
/// styles and standard action types (next, previous, skip).
37+
/// 2. Using the [TooltipActionButton.custom] constructor for fully custom
38+
/// button widgets.
3439
///
35-
/// - `type`: The type of the action button (e.g.,
36-
/// `TooltipDefaultActionType.next`).
40+
/// Tooltip action buttons can be used in two contexts:
41+
/// - As local actions specific to a single showcase tooltip by providing
42+
/// them in [Showcase.tooltipActions].
43+
/// - As global actions that appear in all showcase tooltips by providing
44+
/// them in [ShowcaseView.globalTooltipActions].
3745
///
38-
/// **Optional arguments:**
39-
///
40-
/// - `backgroundColor`: The background color of the button
41-
/// - `textStyle`: The text style for the button label.
42-
/// - `borderRadius`: The border radius of the button. Defaults to a
43-
/// rounded shape.
44-
/// - `padding`: The padding around the button content.
45-
/// - `leadIcon`: An optional leading icon for the button.
46-
/// - `tailIcon`: An optional trailing icon for the button.
47-
/// - `name`: The text for the button label (ignored if `type` is provided).
48-
/// - `onTap`: A callback function triggered when the button is tapped.
49-
/// - `border`: A border to draw around the button.
50-
/// - `hideActionWidgetForShowcase`: A list of `GlobalKey`s of showcases
51-
/// where this action widget should be hidden. This only works for global
52-
/// action widgets.
46+
/// The appearance and position of these buttons are controlled by the
47+
/// [TooltipActionConfig] class, which can define whether the buttons appear
48+
/// inside or outside the tooltip container and how they are aligned.
5349
const TooltipActionButton({
5450
required this.type,
51+
this.borderRadius = const BorderRadius.all(Radius.circular(50)),
52+
this.padding = const EdgeInsets.symmetric(horizontal: 15, vertical: 4),
53+
this.hideActionWidgetForShowcase = const [],
5554
this.backgroundColor,
5655
this.textStyle,
57-
this.borderRadius = const BorderRadius.all(
58-
Radius.circular(50),
59-
),
60-
this.padding = const EdgeInsets.symmetric(
61-
horizontal: 15,
62-
vertical: 4,
63-
),
6456
this.leadIcon,
6557
this.tailIcon,
6658
this.name,
6759
this.onTap,
68-
this.hideActionWidgetForShowcase = const [],
6960
this.border,
7061
}) : button = null;
7162

@@ -83,45 +74,51 @@ class TooltipActionButton {
8374
onTap = null,
8475
border = null;
8576

86-
/// To Provide Background color to the action
77+
/// Background color for the action button.
78+
///
79+
/// If not provided, theme's primary color will be used as default.
8780
final Color? backgroundColor;
8881

89-
/// To Provide borderRadius to the action
82+
/// Border radius for the action button.
9083
///
91-
/// Defaults to const BorderRadius.all(Radius.circular(50)),
84+
/// Defaults to a rounded shape with circular radius of 50.
9285
final BorderRadius? borderRadius;
9386

94-
/// To Provide textStyle to the action text
87+
/// Text style for the button label.
88+
///
89+
/// Controls the appearance of the text inside the button.
9590
final TextStyle? textStyle;
9691

97-
/// To Provide padding to the action widget
98-
///
99-
/// Defaults to const EdgeInsets.symmetric(horizontal: 15,vertical: 4,)
92+
/// Padding inside the action button.
10093
final EdgeInsets? padding;
10194

102-
/// To Provide a custom widget for the action in [TooltipActionButton.custom]
95+
/// A custom widget to use instead of the default button appearance.
96+
///
97+
/// When provided, most other appearance properties are ignored.
10398
final Widget? button;
10499

105-
/// To Provide a leading icon for the action
100+
/// Icon to display before the button text.
106101
final ActionButtonIcon? leadIcon;
107102

108-
/// To Provide a tail icon for the action
103+
/// Icon to display after the button text.
109104
final ActionButtonIcon? tailIcon;
110105

111-
/// To Provide a action type
106+
/// Predefined action type that determines the button's default behavior.
112107
final TooltipDefaultActionType? type;
113108

114-
/// To Provide a text for action
109+
/// Display text for the button.
115110
///
116-
/// If type is provided then it will take type name
111+
/// If not provided, uses the name from the action type.
117112
final String? name;
118113

119-
/// To Provide a onTap for action
114+
/// Callback function triggered when the button is tapped.
120115
///
121-
/// If type is provided then it will take type's OnTap
116+
/// When provided, this overrides the default behavior of the action type.
122117
final VoidCallback? onTap;
123118

124-
/// To Provide a border for action
119+
/// Border to apply around the button.
120+
///
121+
/// Allows for custom border styling such as color, width, and style.
125122
final Border? border;
126123

127124
/// Hides action widgets for the showcase. Add key of particular showcase

lib/src/models/tooltip_action_config.dart

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,40 +36,27 @@ class TooltipActionConfig {
3636
this.crossAxisAlignment = CrossAxisAlignment.start,
3737
this.textBaseline,
3838
}) : assert(
39-
!identical(crossAxisAlignment, CrossAxisAlignment.stretch),
39+
crossAxisAlignment != CrossAxisAlignment.stretch,
4040
'Can not use stretch as height is unbounded',
4141
);
4242

43-
/// Defines tooltip action widget position.
44-
/// It can be inside the tooltip widget or outside.
45-
///
46-
/// Default to [TooltipActionPosition.inside]
43+
/// Defines tooltip action widget position. It can be inside the tooltip
44+
/// widget or outside.
4745
final TooltipActionPosition position;
4846

49-
/// Defines the alignment of actions buttons of tooltip action widget
50-
///
51-
/// Default to [MainAxisAlignment.spaceBetween]
47+
/// Defines the alignment of actions buttons of tooltip action widget.
5248
final MainAxisAlignment alignment;
5349

54-
/// Defines the gap between the actions buttons of tooltip action widget
55-
///
56-
/// Default to 5.0
50+
/// Defines the gap between the actions buttons of tooltip action widget.
5751
final double actionGap;
5852

5953
/// Defines vertically gap between tooltip content and actions.
60-
///
61-
/// Default to 10.0
6254
final double gapBetweenContentAndAction;
6355

6456
/// Defines running direction alignment for the Action widgets.
65-
///
66-
/// Default to [CrossAxisAlignment.start]
6757
final CrossAxisAlignment crossAxisAlignment;
6858

6959
/// If aligning items according to their baseline, which baseline to use.
70-
///
71-
/// This must be set if using baseline alignment. There is no default
72-
/// because there is no way for the framework to know the correct baseline
73-
/// _a priori_.
60+
/// This must be set if using baseline alignment.
7461
final TextBaseline? textBaseline;
7562
}

0 commit comments

Comments
 (0)