DraggableFloatingWidget class
Floats its content over a Stack where the user can drag it, and tucks it against the left or right edge when pushed past it.
Put it inside a Stack: it builds a Positioned and relies on the Stack's clipping to hide the part dragged off-screen.
Example:
Stack(
children: [
const HomeScreen(),
DraggableFloatingWidget(
size: const Size(56, 56),
borderRadius: BorderRadius.circular(28),
builder: (context, onPanUpdate, onPanEnd) => GestureDetector(
onPanUpdate: onPanUpdate,
onPanEnd: onPanEnd,
child: const CircleAvatar(child: Icon(Icons.chat)),
),
),
],
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- DraggableFloatingWidget
Constructors
- DraggableFloatingWidget({Key? key, required Size size, required Widget builder(BuildContext context, GestureDragUpdateCallback onPanUpdate, GestureDragEndCallback onPanEnd), Offset defaultOffset(Size screenSize, Size widgetSize)?, double commitThreshold = 0.5, double peekExtent = 28, BorderRadius borderRadius = BorderRadius.zero})
-
Creates a draggable widget of
sizebuilt bybuilder.const
Properties
- borderRadius → BorderRadius
-
Clips the box to this shape so a rounded child's corners don't show what's painted behind it, e.g.
BorderRadius.circular(16); defaults to none.final - builder → Widget Function(BuildContext context, GestureDragUpdateCallback onPanUpdate, GestureDragEndCallback onPanEnd)
-
Builds the content; attach
onPanUpdateandonPanEndonly where a drag should start, e.g. a header, so the rest can still scroll and tap.final - commitThreshold → double
-
How far past an edge, as a fraction of
size.width - peekExtent, a drag must end to tuck it away; less springs back fully visible.final - defaultOffset → Offset Function(Size screenSize, Size widgetSize)?
-
The starting position from the screen size and size; defaults to near the bottom-right corner.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- peekExtent → double
-
How many pixels stay visible while tucked against an edge.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → Size
-
The content's width and height, e.g.
const Size(48, 48).final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< DraggableFloatingWidget> -
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
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