Unverified Commit 08ee37e1 authored by Ayush Bherwani's avatar Ayush Bherwani Committed by GitHub

[RefreshIndicator] adds strokeWidth parameter to RefreshIndicator (#53344)

parent f9474c29
...@@ -106,9 +106,11 @@ class RefreshIndicator extends StatefulWidget { ...@@ -106,9 +106,11 @@ class RefreshIndicator extends StatefulWidget {
this.notificationPredicate = defaultScrollNotificationPredicate, this.notificationPredicate = defaultScrollNotificationPredicate,
this.semanticsLabel, this.semanticsLabel,
this.semanticsValue, this.semanticsValue,
this.strokeWidth = 2.0
}) : assert(child != null), }) : assert(child != null),
assert(onRefresh != null), assert(onRefresh != null),
assert(notificationPredicate != null), assert(notificationPredicate != null),
assert(strokeWidth != null),
super(key: key); super(key: key);
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
...@@ -153,6 +155,11 @@ class RefreshIndicator extends StatefulWidget { ...@@ -153,6 +155,11 @@ class RefreshIndicator extends StatefulWidget {
/// {@macro flutter.material.progressIndicator.semanticsValue} /// {@macro flutter.material.progressIndicator.semanticsValue}
final String semanticsValue; final String semanticsValue;
/// Defines `strokeWidth` for `RefreshIndicator`.
///
/// By default, the value of `strokeWidth` is 2.0 pixels.
final double strokeWidth;
@override @override
RefreshIndicatorState createState() => RefreshIndicatorState(); RefreshIndicatorState createState() => RefreshIndicatorState();
} }
...@@ -462,6 +469,7 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS ...@@ -462,6 +469,7 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
value: showIndeterminateIndicator ? null : _value.value, value: showIndeterminateIndicator ? null : _value.value,
valueColor: _valueColor, valueColor: _valueColor,
backgroundColor: widget.backgroundColor, backgroundColor: widget.backgroundColor,
strokeWidth: widget.strokeWidth,
); );
}, },
), ),
......
...@@ -455,4 +455,77 @@ void main() { ...@@ -455,4 +455,77 @@ void main() {
expect(layoutCount, 1); expect(layoutCount, 1);
}); });
}
\ No newline at end of file testWidgets('strokeWidth cannot be null in RefreshIndicator', (WidgetTester tester) async {
try {
await tester.pumpWidget(
MaterialApp(
home: RefreshIndicator(
onRefresh: () async {},
strokeWidth: null,
child: ListView(
physics: const AlwaysScrollableScrollPhysics(),
children: <String>['A', 'B', 'C', 'D', 'E', 'F'].map<Widget>((String item) {
return SizedBox(
height: 200.0,
child: Text(item),
);
}).toList(),
),
),
)
);
} on AssertionError catch(_) {
return;
}
fail('The assertion was not thrown when strokeWidth was null');
});
testWidgets('RefreshIndicator responds to strokeWidth', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: RefreshIndicator(
onRefresh: () async {},
child: ListView(
physics: const AlwaysScrollableScrollPhysics(),
children: <String>['A', 'B', 'C', 'D', 'E', 'F'].map<Widget>((String item) {
return SizedBox(
height: 200.0,
child: Text(item),
);
}).toList(),
),
),
)
);
//By default the value of strokeWidth is 2.0
expect(
tester.widget<RefreshIndicator>(find.byType(RefreshIndicator)).strokeWidth,
2.0,
);
await tester.pumpWidget(
MaterialApp(
home: RefreshIndicator(
onRefresh: () async {},
strokeWidth: 4.0,
child: ListView(
physics: const AlwaysScrollableScrollPhysics(),
children: <String>['A', 'B', 'C', 'D', 'E', 'F'].map<Widget>((String item) {
return SizedBox(
height: 200.0,
child: Text(item),
);
}).toList(),
),
),
)
);
expect(
tester.widget<RefreshIndicator>(find.byType(RefreshIndicator)).strokeWidth,
4.0,
);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment