TicketShape class
A widget that renders a ticket-shaped container with rounded corners and circular side notches — similar to a physical boarding pass or event ticket.
This widget both draws the ticket outline (using CustomPaint) and clips its child widget to the same path, ensuring the content fits perfectly within the ticket shape.
The ticket appearance is controlled by:
- borderRadius → Roundness of ticket corners.
- notchRadius → Radius of the circular notches on both sides.
- notchOffsetFactor → How much the notches are horizontally offset (a factor of the notch radius).
- borderColor and borderWidth → Define the ticket border.
- maxWidth → Restricts how wide the ticket can be drawn.
Typically used to display structured information such as flight tickets, concert passes, or coupon layouts.
Example usage:
TicketShape(
borderColor: Colors.deepPurple,
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text('Flight Ticket', style: Theme.of(context).textTheme.titleLarge),
const SizedBox(height: 8),
Text('Passenger: Jenny Simmons'),
],
),
),
)
This widget uses TicketPainter to draw the border and TicketClipper to clip its child content to the ticket outline.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- TicketShape
Constructors
- TicketShape({Key? key, required Widget child, double maxWidth = 420, Color borderColor = Colors.purple, double borderRadius = 18, double notchRadius = 24, double notchOffsetFactor = 0.2, double borderWidth = 1.0})
-
Creates a TicketShape widget that paints and clips content to
a rounded ticket shape with matching border.
const
Properties
- borderColor → Color
-
Color of the ticket border.
final
- borderRadius → double
-
Corner radius of the ticket’s rounded rectangle.
final
- borderWidth → double
-
Thickness of the ticket border line.
final
- child → Widget
-
The widget displayed inside the clipped ticket shape.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- maxWidth → double
-
Maximum width allowed for the ticket layout.
final
- notchOffsetFactor → double
-
Horizontal offset factor applied to the notch centers.
final
- notchRadius → double
-
Radius of the circular side notches.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
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