Unverified Commit 5e19b335 authored by Taha Tesser's avatar Taha Tesser Committed by GitHub

Fix vertical `Stepper` draws connector on the last step (#145703)

fixes [Vertical stepper shows line after last step](https://github.com/flutter/flutter/issues/144376)

### Code sample

<details>
<summary>expand to view the code sample</summary> 

```dart
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: Stepper(
            currentStep: 1,
            steps: const <Step>[
              Step(
                title: Text("Step 1"),
                content: Text("Content 1"),
              ),
              Step(
                title: Text("Step 2"),
                content: Text("Content 2"),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
```

</details>

### Before

![Screenshot 2024-03-25 at 18 36 32](https://github.com/flutter/flutter/assets/48603081/af859a88-7ec8-4432-8eec-f8eb72706b57)

### After
![Screenshot 2024-03-25 at 18 36 24](https://github.com/flutter/flutter/assets/48603081/994325b2-4bd4-44ef-9473-245d3492faf7)
parent 330a2ca2
...@@ -791,7 +791,7 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin { ...@@ -791,7 +791,7 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
width: _stepIconWidth ?? _kStepSize, width: _stepIconWidth ?? _kStepSize,
child: Center( child: Center(
child: SizedBox( child: SizedBox(
width: widget.connectorThickness ?? 1.0, width: !_isLast(index) ? (widget.connectorThickness ?? 1.0) : 0.0,
child: Container( child: Container(
color: _connectorColor(widget.steps[index].isActive), color: _connectorColor(widget.steps[index].isActive),
), ),
......
...@@ -1689,6 +1689,37 @@ testWidgets('Stepper custom indexed controls test', (WidgetTester tester) async ...@@ -1689,6 +1689,37 @@ testWidgets('Stepper custom indexed controls test', (WidgetTester tester) async
expect(mergedStyle.gradient, stepStyle.gradient); expect(mergedStyle.gradient, stepStyle.gradient);
expect(mergedStyle.indexStyle, stepStyle.indexStyle); expect(mergedStyle.indexStyle, stepStyle.indexStyle);
}); });
// This is a regression test for https://github.com/flutter/flutter/issues/144376.
testWidgets('Vertical Stepper does not draw connector on the last step', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Center(
child: Stepper(
currentStep: 1,
steps: const <Step>[
Step(
title: Text('step1'),
content: Text('step1 content'),
),
Step(
title: Text('step2'),
content: Text('step2 content'),
),
],
),
),
),
)
);
final SizedBox lastConnector = tester.widget<SizedBox>(
find.descendant(of: find.byType(PositionedDirectional),
matching: find.byType(SizedBox).last,
));
expect(lastConnector.width, equals(0.0));
});
} }
class _TappableColorWidget extends StatefulWidget { class _TappableColorWidget extends StatefulWidget {
......
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