From 3aa104fe60df4b647cc9c6bc319788db54207117 Mon Sep 17 00:00:00 2001 From: jslavitz Date: Fri, 2 Nov 2018 09:50:14 -0700 Subject: [PATCH] Allows progress indicator height to be controlled by parent (#23540) * Adds functionality for progress indicator height to be controlled by the parent. --- .../lib/src/material/progress_indicator.dart | 6 +- .../material/progress_indicator_test.dart | 66 +++++++++++++++++++ 2 files changed, 69 insertions(+), 3 deletions(-) diff --git a/packages/flutter/lib/src/material/progress_indicator.dart b/packages/flutter/lib/src/material/progress_indicator.dart index 86bea891bf..2576e63209 100644 --- a/packages/flutter/lib/src/material/progress_indicator.dart +++ b/packages/flutter/lib/src/material/progress_indicator.dart @@ -221,9 +221,9 @@ class _LinearProgressIndicatorState extends State with Widget _buildIndicator(BuildContext context, double animationValue, TextDirection textDirection) { return Container( - constraints: const BoxConstraints.tightFor( - width: double.infinity, - height: _kLinearProgressIndicatorHeight, + constraints: const BoxConstraints( + minWidth: double.infinity, + minHeight: _kLinearProgressIndicatorHeight, ), child: CustomPaint( painter: _LinearProgressIndicatorPainter( diff --git a/packages/flutter/test/material/progress_indicator_test.dart b/packages/flutter/test/material/progress_indicator_test.dart index 96eb9dd010..049de287b4 100644 --- a/packages/flutter/test/material/progress_indicator_test.dart +++ b/packages/flutter/test/material/progress_indicator_test.dart @@ -255,4 +255,70 @@ void main() { await tester.pump(const Duration(milliseconds: 1)); expect(tester.hasRunningAnimations, isTrue); }); + + testWidgets('LinearProgressIndicator with height 12.0', (WidgetTester tester) async { + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: Center( + child: SizedBox( + width: 100.0, + height: 12.0, + child: LinearProgressIndicator(value: 0.25), + ), + ), + ), + ); + expect( + find.byType(LinearProgressIndicator), + paints + ..rect(rect: Rect.fromLTRB(0.0, 0.0, 100.0, 12.0)) + ..rect(rect: Rect.fromLTRB(0.0, 0.0, 25.0, 12.0)) + ); + expect(tester.binding.transientCallbackCount, 0); + }); + + testWidgets('LinearProgressIndicator with a height less than the minumum', (WidgetTester tester) async { + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: Center( + child: SizedBox( + width: 100.0, + height: 3.0, + child: LinearProgressIndicator(value: 0.25), + ), + ), + ), + ); + expect( + find.byType(LinearProgressIndicator), + paints + ..rect(rect: Rect.fromLTRB(0.0, 0.0, 100.0, 3.0)) + ..rect(rect: Rect.fromLTRB(0.0, 0.0, 25.0, 3.0)) + ); + expect(tester.binding.transientCallbackCount, 0); + }); + + testWidgets('LinearProgressIndicator with default height', (WidgetTester tester) async { + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: Center( + child: SizedBox( + width: 100.0, + height: 4.0, + child: LinearProgressIndicator(value: 0.25), + ), + ), + ), + ); + expect( + find.byType(LinearProgressIndicator), + paints + ..rect(rect: Rect.fromLTRB(0.0, 0.0, 100.0, 4.0)) + ..rect(rect: Rect.fromLTRB(0.0, 0.0, 25.0, 4.0)) + ); + expect(tester.binding.transientCallbackCount, 0); + }); }