Allows progress indicator height to be controlled by parent (#23540)

* Adds functionality for progress indicator height to be controlled by the parent.
This commit is contained in:
jslavitz
2018-11-02 09:50:14 -07:00
committed by GitHub
parent 00565c2dda
commit 3aa104fe60
2 changed files with 69 additions and 3 deletions

View File

@@ -221,9 +221,9 @@ class _LinearProgressIndicatorState extends State<LinearProgressIndicator> 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(

View File

@@ -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);
});
}