CkShareButton class
A fully adaptive share button and builder widget that provides immediate visual feedback while downloading network/CDN images and presenting the native share sheet.
Supports two usage modes:
- Direct Child Mode: Wrap any widget (Icon, CircleAvatar, custom Button). Automatically manages tap events and animates a loader along its edge or overlay.
- Builder Mode: Uses
builder: (context, share, isLoading)for complete custom UI control.
Example with an Icon or circular button:
CkShareButton(
title: 'Explore this post',
imageUrl: 'https://cdn.example.com/photo.jpg',
deepLinkUrl: 'https://myapp.com/post/123',
child: const Icon(Icons.share),
)
Example with a rounded rectangle button:
CkShareButton(
title: 'Explore this post',
imageUrl: 'https://cdn.example.com/photo.jpg',
deepLinkUrl: 'https://myapp.com/post/123',
borderRadius: BorderRadius.circular(12),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(12),
),
child: const Text('Share Post', style: TextStyle(color: Colors.white)),
),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- CkShareButton
- Available extensions
Constructors
-
const
-
Convenient constructor for builder mode.
const
Properties
- animationDuration → Duration
-
Duration for one complete 360° perimeter loop.
final
- borderRadius → BorderRadius?
-
Border radius for rounded rectangular children.
If null and rectangular, defaults to
BorderRadius.circular(8.0).final - builder → Widget Function(BuildContext context, bool isLoading)?
-
Builder for full custom UI control:
(context, share, isLoading).final - byteImage → ByteData?
-
Raw byte image data to share instead of network URL.
final
- center → Widget
-
Available on Widget, provided by the Alignments extension
no setter - child → Widget?
-
The child widget (e.g. Icon, CircleAvatar, Container, Button).
final
- customLoader → Widget?
-
Custom loader widget for
replaceoroverlaystyles.final - deepLinkUrl → String
-
Deep link URL appended to the shared message.
final
- end → Widget
-
Available on Widget, provided by the Alignments extension
no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- imageUrl → String?
-
Network or CDN image URL to fetch and share.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loaderColor → Color?
-
Color of the active loader or traveling stroke. Defaults to theme primary color.
final
- loaderStyle → CkShareLoaderStyle
-
How the loader is rendered during network image download.
final
- marginZero → Widget
-
Available on Widget, provided by the WidgetMarginX extension
no setter -
Called if an error occurs during downloading or sharing.
final
-
Called when the native share dialog/bottomsheet is presented by the OS.
final
-
Called when image download and share processing starts.
final
-
Called when the share sheet has been presented / completed.
final
- onTap → VoidCallback?
-
Called when the widget is tapped before the share process begins.
final
- paddingOffset → double
-
Outward or inward offset from the child's bounds.
Positive values expand outward (like a halo); negative values inset inward.
final
- paddingZero → Widget
-
Available on Widget, provided by the WidgetPaddingX extension
no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shape → BoxShape?
-
Explicit shape override (
BoxShape.circleorBoxShape.rectangle). If null, automatically infers circle if width == height.final - sliverBox → Widget
-
Available on Widget, provided by the WidgetSliverBoxX extension
no setter - start → Widget
-
Available on Widget, provided by the Alignments extension
no setter - strokeLengthFactor → double
-
Proportion of the perimeter occupied by the traveling beam (0.1 to 0.8).
final
- strokeWidth → double
-
Thickness of the animated edge stroke.
final
- title → String
-
Title / subject to be shared.
final
- trackColor → Color?
-
Background track color underneath the traveling stroke.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< CkShareButton> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
marginAll(
double margin) → Widget -
Available on Widget, provided by the WidgetMarginX extension
-
marginOnly(
{double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0}) → Widget -
Available on Widget, provided by the WidgetMarginX extension
-
marginSymmetric(
{double horizontal = 0.0, double vertical = 0.0}) → Widget -
Available on Widget, provided by the WidgetMarginX extension
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
paddingAll(
double padding) → Widget -
Available on Widget, provided by the WidgetPaddingX extension
-
paddingOnly(
{double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0}) → Widget -
Available on Widget, provided by the WidgetPaddingX extension
-
paddingSymmetric(
{double horizontal = 0.0, double vertical = 0.0}) → Widget -
Available on Widget, provided by the WidgetPaddingX extension
-
toAr(
num width, num height) → Widget -
Available on Widget, provided by the WidgetAspectRatio extension
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited