Unverified Commit 8c05c0a9 authored by Hans Muller's avatar Hans Muller Committed by GitHub

Removed Stepper accentColor dependency (#77732)

parent b15465fc
...@@ -127,46 +127,32 @@ class Step { ...@@ -127,46 +127,32 @@ class Step {
/// ```dart /// ```dart
/// int _index = 0; /// int _index = 0;
/// Widget build(BuildContext context) { /// Widget build(BuildContext context) {
/// return Container( /// return Stepper(
/// height: 300,
/// width: 300,
/// child: Stepper(
/// currentStep: _index, /// currentStep: _index,
/// onStepCancel: () { /// onStepCancel: () {
/// if (_index <= 0) { /// if (_index > 0)
/// return; /// setState(() { _index -= 1; });
/// }
/// setState(() {
/// _index--;
/// });
/// }, /// },
/// onStepContinue: () { /// onStepContinue: () {
/// if (_index >= 1) { /// if (_index <= 0)
/// return; /// setState(() { _index += 1; });
/// }
/// setState(() {
/// _index++;
/// });
/// }, /// },
/// onStepTapped: (index) { /// onStepTapped: (index) {
/// setState(() { /// setState(() { _index = index; });
/// _index = index;
/// });
/// }, /// },
/// steps: [ /// steps: <Step>[
/// Step( /// Step(
/// title: Text("Step 1 title"), /// title: Text('Step 1 title'),
/// content: Container( /// content: Container(
/// alignment: Alignment.centerLeft, /// alignment: Alignment.centerLeft,
/// child: Text("Content for Step 1") /// child: Text('Content for Step 1')
/// ), /// ),
/// ), /// ),
/// Step( /// Step(
/// title: Text("Step 2 title"), /// title: Text('Step 2 title'),
/// content: Text("Content for Step 2"), /// content: Text('Content for Step 2'),
/// ), /// ),
/// ], /// ],
/// ),
/// ); /// );
/// } /// }
/// ``` /// ```
...@@ -372,11 +358,11 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin { ...@@ -372,11 +358,11 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
} }
Color _circleColor(int index) { Color _circleColor(int index) {
final ThemeData themeData = Theme.of(context); final ColorScheme colorScheme = Theme.of(context).colorScheme;
if (!_isDark()) { if (!_isDark()) {
return widget.steps[index].isActive ? themeData.primaryColor : Colors.black38; return widget.steps[index].isActive ? colorScheme.primary : colorScheme.onSurface.withOpacity(0.38);
} else { } else {
return widget.steps[index].isActive ? themeData.accentColor : themeData.backgroundColor; return widget.steps[index].isActive ? colorScheme.secondary : colorScheme.background;
} }
} }
......
...@@ -842,4 +842,49 @@ void main() { ...@@ -842,4 +842,49 @@ void main() {
expect(listView.physics, physics); expect(listView.physics, physics);
} }
}); });
testWidgets('Stepper horizontal size test', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/pull/77732
Widget buildFrame({ bool isActive = true, Brightness? brightness }) {
return MaterialApp(
theme: brightness == Brightness.dark ? ThemeData.dark() : ThemeData.light(),
home: Scaffold(
body: Center(
child: Stepper(
type: StepperType.horizontal,
steps: <Step>[
Step(
title: const Text('step'),
content: const Text('content'),
isActive: isActive,
),
],
),
),
),
);
}
Color? circleFillColor() {
final Finder container = find.widgetWithText(AnimatedContainer, '1');
return (tester.widget<AnimatedContainer>(container).decoration as BoxDecoration?)?.color;
}
// Light theme
final ColorScheme light = ThemeData.light().colorScheme;
await tester.pumpWidget(buildFrame(isActive: true, brightness: Brightness.light));
expect(circleFillColor(), light.primary);
await tester.pumpWidget(buildFrame(isActive: false, brightness: Brightness.light));
await tester.pumpAndSettle();
expect(circleFillColor(), light.onSurface.withOpacity(0.38));
// Dark theme
final ColorScheme dark = ThemeData.dark().colorScheme;
await tester.pumpWidget(buildFrame(isActive: true, brightness: Brightness.dark));
await tester.pumpAndSettle();
expect(circleFillColor(), dark.secondary);
await tester.pumpWidget(buildFrame(isActive: false, brightness: Brightness.dark));
await tester.pumpAndSettle();
expect(circleFillColor(), dark.background);
});
} }
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