From dca164ab2d3ad9e0449298baf7ffeb37743d5ff0 Mon Sep 17 00:00:00 2001 From: Stefano Rodriguez Date: Fri, 29 Sep 2017 00:17:07 +0200 Subject: [PATCH] Fix LinearProgressIndicator constructor (#12282) * Update AUTHORS * Add background and value colors to LinearProgressIndicator * Add tests for LinearProgressIndicator with colors --- AUTHORS | 1 + .../lib/src/material/progress_indicator.dart | 4 ++- .../material/progress_indicator_test.dart | 25 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index b5f24fa5f1..0b099f79a1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -16,3 +16,4 @@ Luke Freeman Vincent Le Quéméner Mike Hoolehan German Saprykin +Stefano Rodriguez diff --git a/packages/flutter/lib/src/material/progress_indicator.dart b/packages/flutter/lib/src/material/progress_indicator.dart index d99681bd9d..8c1670b12e 100644 --- a/packages/flutter/lib/src/material/progress_indicator.dart +++ b/packages/flutter/lib/src/material/progress_indicator.dart @@ -161,7 +161,9 @@ class LinearProgressIndicator extends ProgressIndicator { const LinearProgressIndicator({ Key key, double value, - }) : super(key: key, value: value); + Color backgroundColor, + Animation valueColor, + }) : super(key: key, value: value, backgroundColor: backgroundColor, valueColor: valueColor); @override _LinearProgressIndicatorState createState() => new _LinearProgressIndicatorState(); diff --git a/packages/flutter/test/material/progress_indicator_test.dart b/packages/flutter/test/material/progress_indicator_test.dart index 1bedc24bf9..74c407bac6 100644 --- a/packages/flutter/test/material/progress_indicator_test.dart +++ b/packages/flutter/test/material/progress_indicator_test.dart @@ -143,6 +143,31 @@ void main() { expect(tester.binding.transientCallbackCount, 1); }); + testWidgets('LinearProgressIndicator with colors', (WidgetTester tester) async { + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: const Center( + child: const SizedBox( + width: 200.0, + child: const LinearProgressIndicator( + value: 0.25, + valueColor: const AlwaysStoppedAnimation(Colors.white), + backgroundColor: Colors.black, + ), + ), + ), + ), + ); + + expect( + find.byType(LinearProgressIndicator), + paints + ..rect(rect: new Rect.fromLTRB(0.0, 0.0, 200.0, 6.0)) + ..rect(rect: new Rect.fromLTRB(0.0, 0.0, 50.0, 6.0), color: Colors.white) + ); + }); + testWidgets('CircularProgressIndicator(value: 0.0) can be constructed', (WidgetTester tester) async { await tester.pumpWidget( const Center(