Removed RefreshIndicator accentColor dependency. (#77884)
This commit is contained in:
parent
3839329125
commit
aec2985c47
@ -147,7 +147,7 @@ class RefreshIndicator extends StatefulWidget {
|
||||
final RefreshCallback onRefresh;
|
||||
|
||||
/// The progress indicator's foreground color. The current theme's
|
||||
/// [ThemeData.accentColor] by default.
|
||||
/// [ColorScheme.primary] by default.
|
||||
final Color? color;
|
||||
|
||||
/// The progress indicator's background color. The current theme's
|
||||
@ -229,8 +229,8 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
|
||||
final ThemeData theme = Theme.of(context);
|
||||
_valueColor = _positionController.drive(
|
||||
ColorTween(
|
||||
begin: (widget.color ?? theme.accentColor).withOpacity(0.0),
|
||||
end: (widget.color ?? theme.accentColor).withOpacity(1.0),
|
||||
begin: (widget.color ?? theme.colorScheme.primary).withOpacity(0.0),
|
||||
end: (widget.color ?? theme.colorScheme.primary).withOpacity(1.0),
|
||||
).chain(CurveTween(
|
||||
curve: const Interval(0.0, 1.0 / _kDragSizeFactorLimit)
|
||||
)),
|
||||
@ -245,8 +245,8 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
|
||||
final ThemeData theme = Theme.of(context);
|
||||
_valueColor = _positionController.drive(
|
||||
ColorTween(
|
||||
begin: (widget.color ?? theme.accentColor).withOpacity(0.0),
|
||||
end: (widget.color ?? theme.accentColor).withOpacity(1.0),
|
||||
begin: (widget.color ?? theme.colorScheme.primary).withOpacity(0.0),
|
||||
end: (widget.color ?? theme.colorScheme.primary).withOpacity(1.0),
|
||||
).chain(CurveTween(
|
||||
curve: const Interval(0.0, 1.0 / _kDragSizeFactorLimit)
|
||||
)),
|
||||
|
@ -709,6 +709,42 @@ void main() {
|
||||
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 {
|
||||
refreshCalled = false;
|
||||
Color refreshIndicatorColor = Colors.green;
|
||||
|
Loading…
x
Reference in New Issue
Block a user