mirror of
https://github.com/flutter/flutter
synced 2024-09-17 23:31:55 +00:00
🚀 Add more fields to RefreshProgressIndicator
(#135207)
Resolves #134494
This commit is contained in:
parent
6cde5da5ea
commit
4ed9ab8b23
|
@ -865,8 +865,21 @@ class RefreshProgressIndicator extends CircularProgressIndicator {
|
||||||
super.semanticsLabel,
|
super.semanticsLabel,
|
||||||
super.semanticsValue,
|
super.semanticsValue,
|
||||||
super.strokeCap,
|
super.strokeCap,
|
||||||
|
this.elevation = 2.0,
|
||||||
|
this.indicatorMargin = const EdgeInsets.all(4.0),
|
||||||
|
this.indicatorPadding = const EdgeInsets.all(12.0),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// {@macro flutter.material.material.elevation}
|
||||||
|
final double elevation;
|
||||||
|
|
||||||
|
/// The amount of space by which to inset the whole indicator.
|
||||||
|
/// It accommodates the [elevation] of the indicator.
|
||||||
|
final EdgeInsetsGeometry indicatorMargin;
|
||||||
|
|
||||||
|
/// The amount of space by which to inset the inner refresh indicator.
|
||||||
|
final EdgeInsetsGeometry indicatorPadding;
|
||||||
|
|
||||||
/// Default stroke width.
|
/// Default stroke width.
|
||||||
static const double defaultStrokeWidth = 2.5;
|
static const double defaultStrokeWidth = 2.5;
|
||||||
|
|
||||||
|
@ -913,6 +926,10 @@ class _RefreshProgressIndicatorState extends _CircularProgressIndicatorState {
|
||||||
// Last value received from the widget before null.
|
// Last value received from the widget before null.
|
||||||
double? _lastValue;
|
double? _lastValue;
|
||||||
|
|
||||||
|
/// Force casting the widget as [RefreshProgressIndicator].
|
||||||
|
@override
|
||||||
|
RefreshProgressIndicator get widget => super.widget as RefreshProgressIndicator;
|
||||||
|
|
||||||
// Always show the indeterminate version of the circular progress indicator.
|
// Always show the indeterminate version of the circular progress indicator.
|
||||||
//
|
//
|
||||||
// When value is non-null the sweep of the progress indicator arrow's arc
|
// When value is non-null the sweep of the progress indicator arrow's arc
|
||||||
|
@ -973,13 +990,13 @@ class _RefreshProgressIndicatorState extends _CircularProgressIndicatorState {
|
||||||
child: Container(
|
child: Container(
|
||||||
width: _indicatorSize,
|
width: _indicatorSize,
|
||||||
height: _indicatorSize,
|
height: _indicatorSize,
|
||||||
margin: const EdgeInsets.all(4.0), // accommodate the shadow
|
margin: widget.indicatorMargin,
|
||||||
child: Material(
|
child: Material(
|
||||||
type: MaterialType.circle,
|
type: MaterialType.circle,
|
||||||
color: backgroundColor,
|
color: backgroundColor,
|
||||||
elevation: 2.0,
|
elevation: widget.elevation,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(12.0),
|
padding: widget.indicatorPadding,
|
||||||
child: Opacity(
|
child: Opacity(
|
||||||
opacity: opacity,
|
opacity: opacity,
|
||||||
child: Transform.rotate(
|
child: Transform.rotate(
|
||||||
|
|
|
@ -1183,6 +1183,75 @@ void main() {
|
||||||
|
|
||||||
expect(tester.getSize(find.byType(CircularProgressIndicator)), const Size(36, 36));
|
expect(tester.getSize(find.byType(CircularProgressIndicator)), const Size(36, 36));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgetsWithLeakTracking('RefreshProgressIndicator using fields correctly', (WidgetTester tester) async {
|
||||||
|
Future<void> pumpIndicator(RefreshProgressIndicator indicator) {
|
||||||
|
return tester.pumpWidget(Theme(data: theme, child: indicator));
|
||||||
|
}
|
||||||
|
|
||||||
|
// With default values.
|
||||||
|
await pumpIndicator(const RefreshProgressIndicator());
|
||||||
|
Material material = tester.widget(
|
||||||
|
find.descendant(
|
||||||
|
of: find.byType(RefreshProgressIndicator),
|
||||||
|
matching: find.byType(Material),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
Container container = tester.widget(
|
||||||
|
find.descendant(
|
||||||
|
of: find.byType(RefreshProgressIndicator),
|
||||||
|
matching: find.byType(Container),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
Padding padding = tester.widget(
|
||||||
|
find.descendant(
|
||||||
|
of: find.descendant(
|
||||||
|
of: find.byType(RefreshProgressIndicator),
|
||||||
|
matching: find.byType(Material),
|
||||||
|
),
|
||||||
|
matching: find.byType(Padding),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(material.elevation, 2.0);
|
||||||
|
expect(container.margin, const EdgeInsets.all(4.0));
|
||||||
|
expect(padding.padding, const EdgeInsets.all(12.0));
|
||||||
|
|
||||||
|
// With values provided.
|
||||||
|
const double testElevation = 1.0;
|
||||||
|
const EdgeInsetsGeometry testIndicatorMargin = EdgeInsets.all(6.0);
|
||||||
|
const EdgeInsetsGeometry testIndicatorPadding = EdgeInsets.all(10.0);
|
||||||
|
await pumpIndicator(
|
||||||
|
const RefreshProgressIndicator(
|
||||||
|
elevation: testElevation,
|
||||||
|
indicatorMargin: testIndicatorMargin,
|
||||||
|
indicatorPadding: testIndicatorPadding,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
material = tester.widget(
|
||||||
|
find.descendant(
|
||||||
|
of: find.byType(RefreshProgressIndicator),
|
||||||
|
matching: find.byType(Material),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
container = tester.widget(
|
||||||
|
find.descendant(
|
||||||
|
of: find.byType(RefreshProgressIndicator),
|
||||||
|
matching: find.byType(Container),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
padding = tester.widget(
|
||||||
|
find.descendant(
|
||||||
|
of: find.descendant(
|
||||||
|
of: find.byType(RefreshProgressIndicator),
|
||||||
|
matching: find.byType(Material),
|
||||||
|
),
|
||||||
|
matching: find.byType(Padding),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(material.elevation, testElevation);
|
||||||
|
expect(container.margin, testIndicatorMargin);
|
||||||
|
expect(padding.padding, testIndicatorPadding);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class _RefreshProgressIndicatorGolden extends StatefulWidget {
|
class _RefreshProgressIndicatorGolden extends StatefulWidget {
|
||||||
|
|
Loading…
Reference in a new issue