Unverified Commit aec2985c authored by Darren Austin's avatar Darren Austin Committed by GitHub

Removed RefreshIndicator accentColor dependency. (#77884)

parent 38393291
...@@ -147,7 +147,7 @@ class RefreshIndicator extends StatefulWidget { ...@@ -147,7 +147,7 @@ class RefreshIndicator extends StatefulWidget {
final RefreshCallback onRefresh; final RefreshCallback onRefresh;
/// The progress indicator's foreground color. The current theme's /// The progress indicator's foreground color. The current theme's
/// [ThemeData.accentColor] by default. /// [ColorScheme.primary] by default.
final Color? color; final Color? color;
/// The progress indicator's background color. The current theme's /// The progress indicator's background color. The current theme's
...@@ -229,8 +229,8 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS ...@@ -229,8 +229,8 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
_valueColor = _positionController.drive( _valueColor = _positionController.drive(
ColorTween( ColorTween(
begin: (widget.color ?? theme.accentColor).withOpacity(0.0), begin: (widget.color ?? theme.colorScheme.primary).withOpacity(0.0),
end: (widget.color ?? theme.accentColor).withOpacity(1.0), end: (widget.color ?? theme.colorScheme.primary).withOpacity(1.0),
).chain(CurveTween( ).chain(CurveTween(
curve: const Interval(0.0, 1.0 / _kDragSizeFactorLimit) curve: const Interval(0.0, 1.0 / _kDragSizeFactorLimit)
)), )),
...@@ -245,8 +245,8 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS ...@@ -245,8 +245,8 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
_valueColor = _positionController.drive( _valueColor = _positionController.drive(
ColorTween( ColorTween(
begin: (widget.color ?? theme.accentColor).withOpacity(0.0), begin: (widget.color ?? theme.colorScheme.primary).withOpacity(0.0),
end: (widget.color ?? theme.accentColor).withOpacity(1.0), end: (widget.color ?? theme.colorScheme.primary).withOpacity(1.0),
).chain(CurveTween( ).chain(CurveTween(
curve: const Interval(0.0, 1.0 / _kDragSizeFactorLimit) curve: const Interval(0.0, 1.0 / _kDragSizeFactorLimit)
)), )),
......
...@@ -709,6 +709,42 @@ void main() { ...@@ -709,6 +709,42 @@ void main() {
expect(refreshCalled, false); expect(refreshCalled, false);
}); });
testWidgets('RefreshIndicator color defaults to ColorScheme.primary', (WidgetTester tester) async {
const Color primaryColor = Color(0xff4caf50);
final ThemeData theme = ThemeData.from(colorScheme: const ColorScheme.light().copyWith(primary: primaryColor));
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: StatefulBuilder(
builder: (BuildContext context, StateSetter stateSetter) {
return RefreshIndicator(
triggerMode: RefreshIndicatorTriggerMode.anywhere,
onRefresh: holdRefresh,
child: ListView(
reverse: true,
physics: const AlwaysScrollableScrollPhysics(),
children: const <Widget>[
SizedBox(
height: 200.0,
child: Text('X'),
),
SizedBox(
height: 800.0,
child: Text('Y'),
),
],
),
);
},
),
),
);
await tester.fling(find.text('X'), const Offset(0.0, -300.0), 1000.0);
await tester.pump();
expect(tester.widget<RefreshProgressIndicator>(find.byType(RefreshProgressIndicator)).valueColor!.value, primaryColor);
});
testWidgets('RefreshIndicator.color can be updated at runtime', (WidgetTester tester) async { testWidgets('RefreshIndicator.color can be updated at runtime', (WidgetTester tester) async {
refreshCalled = false; refreshCalled = false;
Color refreshIndicatorColor = Colors.green; Color refreshIndicatorColor = Colors.green;
......
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