LinearPercentIndicator class
A powerful and customizable linear percent indicator widget.
This widget displays a linear progress indicator with extensive customization options including multi-segment support, animation controls, child positioning, and gradient support.
Example usage:
LinearPercentIndicator(
percent: 0.75,
width: 200,
lineHeight: 20,
progressColor: Colors.blue,
backgroundColor: Colors.grey.shade300,
animation: true,
animationDuration: 1000,
leading: Icon(Icons.download),
trailing: Text('75%'),
center: Text('Downloading...'),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- LinearPercentIndicator
Constructors
-
LinearPercentIndicator({Key? key, double percent = 0.0, double? width, double lineHeight = 10.0, Color progressColor = Colors.blue, Color backgroundColor = const Color(0xFFE0E0E0), Gradient? linearGradient, Gradient? backgroundGradient, bool animation = false, int animationDuration = 500, Curve animationCurve = Curves.easeInOut, bool restartAnimation = false, bool animateFromLastPercent = false, Widget? leading, Widget? trailing, Widget? center, LinearChildPosition childPosition = LinearChildPosition.center, BorderRadius? borderRadius, EdgeInsets leadingPadding = const EdgeInsets.only(right: 8), EdgeInsets trailingPadding = const EdgeInsets.only(left: 8), bool fillBackground = false, bool clipLinearGradient = true, VoidCallback? onAnimationEnd, List<
LinearSegment> ? segments, bool showPercentage = false, TextStyle? percentageTextStyle, int percentageDecimals = 0, bool addPercentSign = true, MainAxisAlignment alignment = MainAxisAlignment.start, EdgeInsets padding = EdgeInsets.zero, MaskFilter? maskFilter, bool isRTL = false, Radius? barRadius}) -
Creates a linear percent indicator widget.
const
Properties
- addPercentSign → bool
-
Whether to add percent symbol.
final
- alignment → MainAxisAlignment
-
Alignment of the widget.
final
- animateFromLastPercent → bool
-
Whether to animate from last percent or from 0.
final
- animation → bool
-
Whether to animate progress changes.
final
- animationCurve → Curve
-
The curve for the animation.
final
- animationDuration → int
-
The duration of the animation in milliseconds.
final
- backgroundColor → Color
-
The background color of the progress bar.
final
- backgroundGradient → Gradient?
-
Optional gradient for the background.
final
- barRadius → Radius?
-
Bar radius (deprecated, use borderRadius instead).
final
- borderRadius → BorderRadius?
-
The border radius of the progress bar.
final
- center → Widget?
-
Widget to display in the center (overlay).
final
- childPosition → LinearChildPosition
-
Position of the child widget.
final
- clipLinearGradient → bool
-
Whether to clip the progress bar.
final
- fillBackground → bool
-
Whether to fill the background.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isRTL → bool
-
Whether the progress bar is reversed (right to left).
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- leading → Widget?
-
Widget to display on the left side.
final
- leadingPadding → EdgeInsets
-
Padding around the leading widget.
final
- linearGradient → Gradient?
-
Optional gradient for the progress bar.
If provided, overrides progressColor.
final
- lineHeight → double
-
The height of the progress bar line.
final
- maskFilter → MaskFilter?
-
Mask filter for the progress bar (for glow effects).
final
- onAnimationEnd → VoidCallback?
-
Callback when animation completes.
final
- padding → EdgeInsets
-
Padding around the entire widget.
final
- percent → double
-
The progress value between 0.0 and 1.0.
final
- percentageDecimals → int
-
Number of decimal places for percentage.
final
- percentageTextStyle → TextStyle?
-
Text style for percentage text.
final
- progressColor → Color
-
The color of the progress indicator.
final
- restartAnimation → bool
-
Whether to restart animation from 0 when percent changes.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
segments
→ List<
LinearSegment> ? -
Multi-segment configuration.
final
- showPercentage → bool
-
Whether to show percentage text in center.
final
- trailing → Widget?
-
Widget to display on the right side.
final
- trailingPadding → EdgeInsets
-
Padding around the trailing widget.
final
- width → double?
-
The width of the progress bar. If null, uses available space.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< LinearPercentIndicator> -
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