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, /// currentStep: _index,
/// width: 300, /// onStepCancel: () {
/// child: Stepper( /// if (_index > 0)
/// currentStep: _index, /// setState(() { _index -= 1; });
/// onStepCancel: () { /// },
/// if (_index <= 0) { /// onStepContinue: () {
/// return; /// if (_index <= 0)
/// } /// setState(() { _index += 1; });
/// setState(() { /// },
/// _index--; /// onStepTapped: (index) {
/// }); /// setState(() { _index = index; });
/// }, /// },
/// onStepContinue: () { /// steps: <Step>[
/// if (_index >= 1) { /// Step(
/// return; /// title: Text('Step 1 title'),
/// } /// content: Container(
/// setState(() { /// alignment: Alignment.centerLeft,
/// _index++; /// child: Text('Content for Step 1')
/// });
/// },
/// onStepTapped: (index) {
/// setState(() {
/// _index = index;
/// });
/// },
/// steps: [
/// Step(
/// title: Text("Step 1 title"),
/// content: Container(
/// alignment: Alignment.centerLeft,
/// child: Text("Content for Step 1")
/// ),
/// ), /// ),
/// Step( /// ),
/// title: Text("Step 2 title"), /// Step(
/// content: Text("Content for Step 2"), /// title: Text('Step 2 title'),
/// ), /// 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