[RefreshIndicator] adds strokeWidth parameter to RefreshIndicator (#53344)
This commit is contained in:
parent
f9474c2946
commit
08ee37e1c1
@ -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 {
|
|||||||
/// {@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
|
|||||||
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() {
|
|||||||
|
|
||||||
expect(layoutCount, 1);
|
expect(layoutCount, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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,
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user