diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml
index 30bc375..5b19362 100644
--- a/.github/workflows/master.yml
+++ b/.github/workflows/master.yml
@@ -12,9 +12,9 @@ jobs:
- name: 'Checkout'
uses: actions/checkout@v1
- name: 'Dry-run'
- uses: ilteoood/actions-flutter-pub-publisher@master
+ uses: Omega365/actions-flutter-pub-publisher@master
with:
credential: ${{secrets.CREDENTIAL_JSON}}
flutter_package: true
skip_test: true
- dry_run: true
\ No newline at end of file
+ dry_run: true
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index e3daf02..aefbea7 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
-
- uses: actions/checkout@v1
+ uses: actions/checkout@v3
-
continue-on-error: true
env:
@@ -33,16 +33,16 @@ jobs:
run: "echo ${{ steps.config.outputs.version_name }}"
-
if: "steps.config.outputs.version_name == steps.previoustag.outputs.tag"
- name: "Compare Vresion"
+ name: "Compare Version"
run: |
echo 'The version from your pubspec.yaml is the same as Release, Please update the version'
exit 1
-
- run: "echo ${{ steps.config.outputs.version_name }} > version.txt\n"
+ run: "echo ${{ steps.config.outputs.version_name }} > version.txt"
shell: bash
-
name: "Upload New Version"
- uses: actions/upload-artifact@v1
+ uses: actions/upload-artifact@v4
with:
name: home
path: version.txt
@@ -53,10 +53,10 @@ jobs:
steps:
-
name: Checkout
- uses: actions/checkout@v1
+ uses: actions/checkout@v3
-
name: "Publish Package"
- uses: ilteoood/actions-flutter-pub-publisher@master
+ uses: Omega365/actions-flutter-pub-publisher@master
with:
credential: "${{secrets.CREDENTIAL_JSON}}"
dry_run: false
@@ -70,7 +70,7 @@ jobs:
steps:
-
name: "Download New Version"
- uses: actions/download-artifact@v1
+ uses: actions/download-artifact@v4
with:
name: home
-
diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist
index 9367d48..9625e10 100644
--- a/example/ios/Flutter/AppFrameworkInfo.plist
+++ b/example/ios/Flutter/AppFrameworkInfo.plist
@@ -21,6 +21,6 @@
CFBundleVersion
1.0
MinimumOSVersion
- 8.0
+ 11.0
diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj
index 14ac4c4..a827609 100644
--- a/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/example/ios/Runner.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 46;
+ objectVersion = 54;
objects = {
/* Begin PBXBuildFile section */
@@ -141,7 +141,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0910;
+ LastUpgradeCheck = 1300;
ORGANIZATIONNAME = "The Chromium Authors";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
@@ -186,10 +186,12 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
+ alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
+ "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
@@ -200,6 +202,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
+ alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
@@ -292,7 +295,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -339,7 +342,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
index 1263ac8..1c19f4b 100644
--- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
+++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
@@ -1,6 +1,6 @@
UIViewControllerBasedStatusBarAppearance
+ CADisableMinimumFrameDurationOnPhone
+
+ UIApplicationSupportsIndirectInputEvents
+
diff --git a/example/lib/sample_circular_page.dart b/example/lib/sample_circular_page.dart
index 61a55c5..bf900ad 100644
--- a/example/lib/sample_circular_page.dart
+++ b/example/lib/sample_circular_page.dart
@@ -337,6 +337,72 @@ class _SampleCircularPageState extends State {
arcBackgroundColor: Colors.transparent,
arcType: ArcType.HALF,
),
+ const SizedBox(height: 20),
+ Padding(
+ padding: const EdgeInsets.only(bottom: 18.0),
+ child: Center(
+ child: Text(
+ "With different border color",
+ style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17.0),
+ ),
+ ),
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceEvenly,
+ children: [
+ CircularPercentIndicator(
+ radius: 40.0,
+ progressColor: Colors.yellow,
+ progressBorderColor: Colors.green,
+ percent: .2,
+ lineWidth: 15,
+ center: Text(
+ "20.0%",
+ style:
+ TextStyle(fontWeight: FontWeight.bold, fontSize: 12.0),
+ ),
+ backgroundWidth: 15,
+ fillColor: Colors.transparent,
+ circularStrokeCap: CircularStrokeCap.round,
+ arcBackgroundColor: Colors.yellow[200],
+ arcType: ArcType.FULL,
+ ),
+ CircularPercentIndicator(
+ radius: 40.0,
+ progressColor: Colors.white,
+ progressBorderColor: Colors.blue,
+ percent: .9,
+ lineWidth: 10,
+ center: Text(
+ "90.0%",
+ style:
+ TextStyle(fontWeight: FontWeight.bold, fontSize: 12.0),
+ ),
+ backgroundWidth: 15,
+ fillColor: Colors.transparent,
+ circularStrokeCap: CircularStrokeCap.round,
+ arcBackgroundColor: Colors.transparent,
+ arcType: ArcType.FULL,
+ ),
+ CircularPercentIndicator(
+ radius: 40.0,
+ progressColor: Colors.red,
+ progressBorderColor: Colors.black,
+ percent: .4,
+ lineWidth: 10,
+ backgroundWidth: 15,
+ fillColor: Colors.transparent,
+ circularStrokeCap: CircularStrokeCap.round,
+ arcBackgroundColor: Colors.grey,
+ arcType: ArcType.FULL,
+ center: Text(
+ "40.0%",
+ style:
+ TextStyle(fontWeight: FontWeight.bold, fontSize: 12.0),
+ ),
+ ),
+ ],
+ ),
],
),
),
diff --git a/example/lib/sample_linear_page.dart b/example/lib/sample_linear_page.dart
index 7098340..e866d15 100644
--- a/example/lib/sample_linear_page.dart
+++ b/example/lib/sample_linear_page.dart
@@ -275,6 +275,20 @@ class _SampleLinearPageState extends State {
),
),
Text('Custom Edges'),
+ Padding(
+ padding: EdgeInsets.all(15),
+ child: LinearPercentIndicator(
+ lineHeight: 20,
+ center: Text('90%'),
+ progressColor: Colors.white,
+ progressBorderColor: Colors.green,
+ barRadius: Radius.elliptical(5, 10),
+ percent: .9,
+ animation: true,
+ animationDuration: 1400,
+ ),
+ ),
+ Text('Custom Border Color'),
],
),
),
diff --git a/example/pubspec.lock b/example/pubspec.lock
index 1940e8e..1d4bbd0 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -5,35 +5,47 @@ packages:
dependency: transitive
description:
name: characters
- url: "https://pub.dartlang.org"
+ sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
+ url: "https://pub.dev"
source: hosted
- version: "1.2.0"
+ version: "1.2.1"
collection:
dependency: transitive
description:
name: collection
- url: "https://pub.dartlang.org"
+ sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
+ url: "https://pub.dev"
source: hosted
- version: "1.16.0"
+ version: "1.17.0"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
+ js:
+ dependency: transitive
+ description:
+ name: js
+ sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.6.5"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
- url: "https://pub.dartlang.org"
+ sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
+ url: "https://pub.dev"
source: hosted
- version: "0.1.4"
+ version: "0.2.0"
meta:
dependency: transitive
description:
name: meta
- url: "https://pub.dartlang.org"
+ sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
+ url: "https://pub.dev"
source: hosted
- version: "1.7.0"
+ version: "1.8.0"
percent_indicator:
dependency: "direct main"
description:
@@ -50,9 +62,10 @@ packages:
dependency: transitive
description:
name: vector_math
- url: "https://pub.dartlang.org"
+ sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
+ url: "https://pub.dev"
source: hosted
- version: "2.1.2"
+ version: "2.1.4"
sdks:
- dart: ">=2.14.0 <3.0.0"
+ dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.12.0"
diff --git a/lib/circular_percent_indicator.dart b/lib/circular_percent_indicator.dart
index 617aced..65685d6 100644
--- a/lib/circular_percent_indicator.dart
+++ b/lib/circular_percent_indicator.dart
@@ -37,6 +37,9 @@ class CircularPercentIndicator extends StatefulWidget {
///First color applied to the complete circle
final Color fillColor;
+ ///Color of the border of the progress bar , default = null
+ final Color? progressBorderColor;
+
///Color of the background of the circle , default = transparent
final Color backgroundColor;
@@ -70,6 +73,9 @@ class CircularPercentIndicator extends StatefulWidget {
/// set true if you want to animate the linear from the last percent value you set
final bool animateFromLastPercent;
+ /// set to false if you do not want the default behavior of initially animating up from 0%
+ final bool animateToInitialPercent;
+
/// set false if you don't want to preserve the state of the widget
final bool addAutomaticKeepAlive;
@@ -101,6 +107,9 @@ class CircularPercentIndicator extends StatefulWidget {
/// Set to true if you want to rotate linear gradient in accordance to the [startAngle].
final bool rotateLinearGradient;
+ /// Return current percent value if animation is true.
+ final Function(double value)? onPercentValue;
+
CircularPercentIndicator({
Key? key,
this.percent = 0.0,
@@ -123,6 +132,7 @@ class CircularPercentIndicator extends StatefulWidget {
this.arcBackgroundColor,
this.arcType,
this.animateFromLastPercent = false,
+ this.animateToInitialPercent = true,
this.reverse = false,
this.curve = Curves.linear,
this.maskFilter,
@@ -130,6 +140,8 @@ class CircularPercentIndicator extends StatefulWidget {
this.onAnimationEnd,
this.widgetIndicator,
this.rotateLinearGradient = false,
+ this.progressBorderColor,
+ this.onPercentValue,
}) : super(key: key) {
if (linearGradient != null && progressColor != null) {
throw ArgumentError(
@@ -171,15 +183,17 @@ class _CircularPercentIndicatorState extends State
@override
void initState() {
if (widget.animation) {
+ if (!widget.animateToInitialPercent) _percent = widget.percent;
_animationController = AnimationController(
vsync: this,
duration: Duration(milliseconds: widget.animationDuration),
);
- _animation = Tween(begin: 0.0, end: widget.percent).animate(
+ _animation = Tween(begin: _percent, end: widget.percent).animate(
CurvedAnimation(parent: _animationController!, curve: widget.curve),
)..addListener(() {
setState(() {
_percent = _animation!.value;
+ widget.onPercentValue?.call(_percent);
});
if (widget.restartAnimation && _percent == 1.0) {
_animationController!.repeat(min: 0, max: 1.0);
@@ -250,6 +264,7 @@ class _CircularPercentIndicatorState extends State
painter: _CirclePainter(
progress: _percent * 360,
progressColor: widget.progressColor,
+ progressBorderColor: widget.progressBorderColor,
backgroundColor: widget.backgroundColor,
startAngle: widget.startAngle,
circularStrokeCap: widget.circularStrokeCap,
@@ -317,7 +332,8 @@ class _CircularPercentIndicatorState extends State
double getCurrentPercent(double percent) {
if (widget.arcType != null) {
final angle = _getStartAngleFixedMargin(widget.arcType!).fixedStartAngle;
- final fixedPercent = 1.0 / widget.percent * _percent;
+ final fixedPercent =
+ widget.percent > 0 ? 1.0 / widget.percent * _percent : 0;
late double margin;
if (widget.arcType == ArcType.HALF) {
margin = 180 * widget.percent;
@@ -363,12 +379,14 @@ class _ArcAngles {
class _CirclePainter extends CustomPainter {
final Paint _paintBackground = Paint();
final Paint _paintLine = Paint();
+ final Paint _paintLineBorder = Paint();
final Paint _paintBackgroundStartAngle = Paint();
final double lineWidth;
final double backgroundWidth;
final double progress;
final double radius;
final Color progressColor;
+ final Color? progressBorderColor;
final Color backgroundColor;
final CircularStrokeCap circularStrokeCap;
final double startAngle;
@@ -386,6 +404,7 @@ class _CirclePainter extends CustomPainter {
required this.radius,
required this.progressColor,
required this.backgroundColor,
+ this.progressBorderColor,
this.startAngle = 0.0,
this.circularStrokeCap = CircularStrokeCap.butt,
this.linearGradient,
@@ -409,8 +428,16 @@ class _CirclePainter extends CustomPainter {
_paintLine.color = progressColor;
_paintLine.style = PaintingStyle.stroke;
- _paintLine.strokeWidth = lineWidth;
+ _paintLine.strokeWidth =
+ progressBorderColor != null ? lineWidth - 2 : lineWidth;
_paintLine.strokeCap = circularStrokeCap.strokeCap;
+
+ if (progressBorderColor != null) {
+ _paintLineBorder.color = progressBorderColor!;
+ _paintLineBorder.style = PaintingStyle.stroke;
+ _paintLineBorder.strokeWidth = lineWidth;
+ _paintLineBorder.strokeCap = circularStrokeCap.strokeCap;
+ }
}
@override
@@ -428,7 +455,7 @@ class _CirclePainter extends CustomPainter {
}
if (maskFilter != null) {
- _paintLine.maskFilter = maskFilter;
+ _paintLineBorder.maskFilter = _paintLine.maskFilter = maskFilter;
}
if (linearGradient != null) {
if (rotateLinearGradient && progress > 0) {
@@ -436,7 +463,7 @@ class _CirclePainter extends CustomPainter {
if (_paintLine.strokeCap != StrokeCap.butt) {
correction = math.atan(_paintLine.strokeWidth / 2 / radius);
}
- _paintLine.shader = SweepGradient(
+ _paintLineBorder.shader = _paintLine.shader = SweepGradient(
transform: reverse
? GradientRotation(
radians(-90 - progress + startAngle) - correction)
@@ -451,7 +478,8 @@ class _CirclePainter extends CustomPainter {
Rect.fromCircle(center: center, radius: radius),
);
} else if (!rotateLinearGradient) {
- _paintLine.shader = linearGradient!.createShader(
+ _paintLineBorder.shader =
+ _paintLine.shader = linearGradient!.createShader(
Rect.fromCircle(center: center, radius: radius),
);
}
@@ -472,6 +500,18 @@ class _CirclePainter extends CustomPainter {
radians(360 * startAngleFixedMargin - 90.0 + fixedStartAngle)
.toDouble();
final end = radians(-progress * startAngleFixedMargin).toDouble();
+ if (progressBorderColor != null) {
+ canvas.drawArc(
+ Rect.fromCircle(
+ center: center,
+ radius: radius,
+ ),
+ start,
+ end,
+ false,
+ _paintLineBorder,
+ );
+ }
canvas.drawArc(
Rect.fromCircle(
center: center,
@@ -485,6 +525,18 @@ class _CirclePainter extends CustomPainter {
} else {
final start = radians(-90.0 + fixedStartAngle).toDouble();
final end = radians(progress * startAngleFixedMargin).toDouble();
+ if (progressBorderColor != null) {
+ canvas.drawArc(
+ Rect.fromCircle(
+ center: center,
+ radius: radius,
+ ),
+ start,
+ end,
+ false,
+ _paintLineBorder,
+ );
+ }
canvas.drawArc(
Rect.fromCircle(
center: center,
diff --git a/lib/linear_percent_indicator.dart b/lib/linear_percent_indicator.dart
index 7bc68df..6790aa5 100644
--- a/lib/linear_percent_indicator.dart
+++ b/lib/linear_percent_indicator.dart
@@ -3,6 +3,10 @@ import 'package:flutter/material.dart';
@Deprecated('This property is no longer used, please use barRadius instead.')
enum LinearStrokeCap { butt, round, roundAll }
+extension ExtDouble on double {
+ bool get isZero => this.toString() == '0.0';
+}
+
// ignore: must_be_immutable
class LinearPercentIndicator extends StatefulWidget {
///Percent value between 0.0 and 1.0
@@ -15,6 +19,9 @@ class LinearPercentIndicator extends StatefulWidget {
///Color of the background of the Line , default = transparent
final Color fillColor;
+ ///Color of the border of the progress bar , default = null
+ final Color? progressBorderColor;
+
///First color applied to the complete line
Color get backgroundColor => _backgroundColor;
late Color _backgroundColor;
@@ -57,6 +64,9 @@ class LinearPercentIndicator extends StatefulWidget {
/// set true if you want to animate the linear from the last percent value you set
final bool animateFromLastPercent;
+ /// set to false if you do not want the default behavior of initially animating up from 0%
+ final bool animateToInitialPercent;
+
/// If present, this will make the progress bar colored by this gradient.
///
/// This will override [progressColor]. It is an error to provide both.
@@ -88,6 +98,9 @@ class LinearPercentIndicator extends StatefulWidget {
/// Display a widget indicator at the end of the progress. It only works when `animation` is true
final Widget? widgetIndicator;
+ /// Return current percent value if animation is true.
+ final Function(double value)? onPercentValue;
+
LinearPercentIndicator({
Key? key,
this.fillColor = Colors.transparent,
@@ -101,6 +114,7 @@ class LinearPercentIndicator extends StatefulWidget {
this.animation = false,
this.animationDuration = 500,
this.animateFromLastPercent = false,
+ this.animateToInitialPercent = true,
this.isRTL = false,
this.leading,
this.trailing,
@@ -116,6 +130,8 @@ class LinearPercentIndicator extends StatefulWidget {
this.restartAnimation = false,
this.onAnimationEnd,
this.widgetIndicator,
+ this.progressBorderColor,
+ this.onPercentValue,
}) : super(key: key) {
if (linearGradient != null && progressColor != null) {
throw ArgumentError(
@@ -173,14 +189,16 @@ class _LinearPercentIndicatorState extends State
}
});
if (widget.animation) {
+ if (!widget.animateToInitialPercent) _percent = widget.percent;
_animationController = AnimationController(
vsync: this,
duration: Duration(milliseconds: widget.animationDuration));
- _animation = Tween(begin: 0.0, end: widget.percent).animate(
+ _animation = Tween(begin: _percent, end: widget.percent).animate(
CurvedAnimation(parent: _animationController!, curve: widget.curve),
)..addListener(() {
setState(() {
_percent = _animation!.value;
+ widget.onPercentValue?.call(_percent);
});
if (widget.restartAnimation && _percent == 1.0) {
_animationController!.repeat(min: 0, max: 1.0);
@@ -244,50 +262,55 @@ class _LinearPercentIndicatorState extends State
final hasSetWidth = widget.width != null;
final percentPositionedHorizontal =
_containerWidth * _percent - _indicatorWidth / 3;
- var containerWidget = Container(
- width: hasSetWidth ? widget.width : double.infinity,
- height: widget.lineHeight,
- padding: widget.padding,
- child: Stack(
- clipBehavior: Clip.none,
- children: [
- CustomPaint(
- key: _containerKey,
- painter: _LinearPainter(
- isRTL: widget.isRTL,
- progress: _percent,
- progressColor: widget.progressColor,
- linearGradient: widget.linearGradient,
- backgroundColor: widget.backgroundColor,
- barRadius: widget.barRadius ??
- Radius.zero, // If radius is not defined, set it to zero
- linearGradientBackgroundColor:
- widget.linearGradientBackgroundColor,
- maskFilter: widget.maskFilter,
- clipLinearGradient: widget.clipLinearGradient,
+ //LayoutBuilder is used to get the size of the container where the widget is rendered
+ var containerWidget = LayoutBuilder(builder: (context, constraints) {
+ _containerWidth = constraints.maxWidth;
+ _containerHeight = constraints.maxHeight;
+ return Container(
+ width: hasSetWidth ? widget.width : double.infinity,
+ height: widget.lineHeight,
+ padding: widget.padding,
+ child: Stack(
+ clipBehavior: Clip.none,
+ children: [
+ CustomPaint(
+ key: _containerKey,
+ painter: _LinearPainter(
+ isRTL: widget.isRTL,
+ progress: _percent,
+ progressColor: widget.progressColor,
+ linearGradient: widget.linearGradient,
+ backgroundColor: widget.backgroundColor,
+ barRadius: widget.barRadius ??
+ Radius.zero, // If radius is not defined, set it to zero
+ linearGradientBackgroundColor:
+ widget.linearGradientBackgroundColor,
+ maskFilter: widget.maskFilter,
+ clipLinearGradient: widget.clipLinearGradient,
+ ),
+ child: (widget.center != null)
+ ? Center(child: widget.center)
+ : Container(),
),
- child: (widget.center != null)
- ? Center(child: widget.center)
- : Container(),
- ),
- if (widget.widgetIndicator != null && _indicatorWidth == 0)
- Opacity(
- opacity: 0.0,
- key: _keyIndicator,
- child: widget.widgetIndicator,
- ),
- if (widget.widgetIndicator != null &&
- _containerWidth > 0 &&
- _indicatorWidth > 0)
- Positioned(
- right: widget.isRTL ? percentPositionedHorizontal : null,
- left: !widget.isRTL ? percentPositionedHorizontal : null,
- top: _containerHeight / 2 - _indicatorHeight,
- child: widget.widgetIndicator!,
- ),
- ],
- ),
- );
+ if (widget.widgetIndicator != null && _indicatorWidth == 0)
+ Opacity(
+ opacity: 0.0,
+ key: _keyIndicator,
+ child: widget.widgetIndicator,
+ ),
+ if (widget.widgetIndicator != null &&
+ _containerWidth > 0 &&
+ _indicatorWidth > 0)
+ Positioned(
+ right: widget.isRTL ? percentPositionedHorizontal : null,
+ left: !widget.isRTL ? percentPositionedHorizontal : null,
+ top: _containerHeight / 2 - _indicatorHeight,
+ child: widget.widgetIndicator!,
+ ),
+ ],
+ ),
+ );
+ });
if (hasSetWidth) {
items.add(containerWidget);
@@ -320,9 +343,11 @@ class _LinearPercentIndicatorState extends State
class _LinearPainter extends CustomPainter {
final Paint _paintBackground = new Paint();
final Paint _paintLine = new Paint();
+ final Paint _paintLineBorder = new Paint();
final double progress;
final bool isRTL;
final Color progressColor;
+ final Color? progressBorderColor;
final Color backgroundColor;
final Radius barRadius;
final LinearGradient? linearGradient;
@@ -336,6 +361,7 @@ class _LinearPainter extends CustomPainter {
required this.progressColor,
required this.backgroundColor,
required this.barRadius,
+ this.progressBorderColor,
this.linearGradient,
this.maskFilter,
required this.clipLinearGradient,
@@ -343,9 +369,14 @@ class _LinearPainter extends CustomPainter {
}) {
_paintBackground.color = backgroundColor;
- _paintLine.color = progress.toString() == "0.0"
- ? progressColor.withOpacity(0.0)
- : progressColor;
+ _paintLine.color =
+ progress == 0 ? progressColor.withOpacity(0.0) : progressColor;
+
+ if (progressBorderColor != null) {
+ _paintLineBorder.color = progress == 0
+ ? progressBorderColor!.withOpacity(0.0)
+ : progressBorderColor!;
+ }
}
@override
@@ -358,6 +389,7 @@ class _LinearPainter extends CustomPainter {
canvas.clipPath(backgroundPath);
if (maskFilter != null) {
+ _paintLineBorder.maskFilter = maskFilter;
_paintLine.maskFilter = maskFilter;
}
@@ -371,8 +403,13 @@ class _LinearPainter extends CustomPainter {
// Then draw progress line
final xProgress = size.width * progress;
Path linePath = Path();
+ Path linePathBorder = Path();
+ double factor = progressBorderColor != null ? 2 : 0;
+ double correction = factor * 2; //Left and right or top an down
if (isRTL) {
if (linearGradient != null) {
+ _paintLineBorder.shader =
+ _createGradientShaderRightToLeft(size, xProgress);
_paintLine.shader = _createGradientShaderRightToLeft(size, xProgress);
}
linePath.addRRect(RRect.fromRectAndRadius(
@@ -381,10 +418,21 @@ class _LinearPainter extends CustomPainter {
barRadius));
} else {
if (linearGradient != null) {
+ _paintLineBorder.shader =
+ _createGradientShaderLeftToRight(size, xProgress);
_paintLine.shader = _createGradientShaderLeftToRight(size, xProgress);
}
+ if (progressBorderColor != null) {
+ linePathBorder.addRRect(RRect.fromRectAndRadius(
+ Rect.fromLTWH(0, 0, xProgress, size.height), barRadius));
+ }
linePath.addRRect(RRect.fromRectAndRadius(
- Rect.fromLTWH(0, 0, xProgress, size.height), barRadius));
+ Rect.fromLTWH(
+ factor, factor, xProgress - correction, size.height - correction),
+ barRadius));
+ }
+ if (progressBorderColor != null) {
+ canvas.drawPath(linePathBorder, _paintLineBorder);
}
canvas.drawPath(linePath, _paintLine);
}
diff --git a/pubspec.lock b/pubspec.lock
index 8910fc6..9b2215e 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -5,51 +5,50 @@ packages:
dependency: transitive
description:
name: async
- url: "https://pub.dartlang.org"
+ sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
+ url: "https://pub.dev"
source: hosted
- version: "2.8.2"
+ version: "2.10.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
- url: "https://pub.dartlang.org"
+ sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
+ url: "https://pub.dev"
source: hosted
- version: "2.1.0"
+ version: "2.1.1"
characters:
dependency: transitive
description:
name: characters
- url: "https://pub.dartlang.org"
+ sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
+ url: "https://pub.dev"
source: hosted
- version: "1.2.0"
- charcode:
- dependency: transitive
- description:
- name: charcode
- url: "https://pub.dartlang.org"
- source: hosted
- version: "1.3.1"
+ version: "1.2.1"
clock:
dependency: transitive
description:
name: clock
- url: "https://pub.dartlang.org"
+ sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
+ url: "https://pub.dev"
source: hosted
- version: "1.1.0"
+ version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
- url: "https://pub.dartlang.org"
+ sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
+ url: "https://pub.dev"
source: hosted
- version: "1.16.0"
+ version: "1.17.0"
fake_async:
dependency: transitive
description:
name: fake_async
- url: "https://pub.dartlang.org"
+ sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
+ url: "https://pub.dev"
source: hosted
- version: "1.3.0"
+ version: "1.3.1"
flutter:
dependency: "direct main"
description: flutter
@@ -60,34 +59,46 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
+ js:
+ dependency: transitive
+ description:
+ name: js
+ sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.6.5"
matcher:
dependency: transitive
description:
name: matcher
- url: "https://pub.dartlang.org"
+ sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72"
+ url: "https://pub.dev"
source: hosted
- version: "0.12.11"
+ version: "0.12.13"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
- url: "https://pub.dartlang.org"
+ sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
+ url: "https://pub.dev"
source: hosted
- version: "0.1.4"
+ version: "0.2.0"
meta:
dependency: transitive
description:
name: meta
- url: "https://pub.dartlang.org"
+ sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
+ url: "https://pub.dev"
source: hosted
- version: "1.7.0"
+ version: "1.8.0"
path:
dependency: transitive
description:
name: path
- url: "https://pub.dartlang.org"
+ sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b
+ url: "https://pub.dev"
source: hosted
- version: "1.8.1"
+ version: "1.8.2"
sky_engine:
dependency: transitive
description: flutter
@@ -97,51 +108,58 @@ packages:
dependency: transitive
description:
name: source_span
- url: "https://pub.dartlang.org"
+ sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
+ url: "https://pub.dev"
source: hosted
- version: "1.8.2"
+ version: "1.9.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
- url: "https://pub.dartlang.org"
+ sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
+ url: "https://pub.dev"
source: hosted
- version: "1.10.0"
+ version: "1.11.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
- url: "https://pub.dartlang.org"
+ sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
+ url: "https://pub.dev"
source: hosted
- version: "2.1.0"
+ version: "2.1.1"
string_scanner:
dependency: transitive
description:
name: string_scanner
- url: "https://pub.dartlang.org"
+ sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
+ url: "https://pub.dev"
source: hosted
- version: "1.1.0"
+ version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
- url: "https://pub.dartlang.org"
+ sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
+ url: "https://pub.dev"
source: hosted
- version: "1.2.0"
+ version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
- url: "https://pub.dartlang.org"
+ sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206
+ url: "https://pub.dev"
source: hosted
- version: "0.4.9"
+ version: "0.4.16"
vector_math:
dependency: transitive
description:
name: vector_math
- url: "https://pub.dartlang.org"
+ sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
+ url: "https://pub.dev"
source: hosted
- version: "2.1.2"
+ version: "2.1.4"
sdks:
- dart: ">=2.17.0-0 <3.0.0"
+ dart: ">=2.18.0 <3.0.0"
flutter: ">=2.12.0"