Repository: flutter/flutter
File: packages/flutter/test/widgets/semantics_keep_alive_offstage_test.dart (Dart)

Code before:
      expect(tester.widgetList(find.widgetWithText(ProblemWidget, initialLabel)), hasLength(0));
      expect(tester.widgetList(find.widgetWithText(ProblemWidget, newLabel)), hasLength(1));
      expect(semantics, isNot(includesNodeWith(label: initialLabel)));
      expect(semantics, includesNodeWith(label: newLabel));

      semantics.dispose();
    },
  );
}

final Key paddingWidget = GlobalKey();

Widget _buildTestWidget({
  required bool extraPadding,
  required String text,
  required ScrollController controller,
}) {
  return TestWidgetsApp(
    home: Column(
      children: <Widget>[
        Expanded(child: Container()),
        SizedBox(
          height: 500.0,
          child: ListView(
            controller: controller,
            children: List<Widget>.generate(10, (int i) {
              return Container(
                color: i.isEven ? const Color(0xFFFF0000) : const Color(0xFF0000FF),
                height: 250.0,
                child: Text('Item $i'),
              );
            })..add(ProblemWidget(extraPadding: extraPadding, text: text)),
          ),
        ),
        Expanded(child: Container()),
      ],
    ),
  );
}

class ProblemWidget extends StatefulWidget {
  const ProblemWidget({super.key, required this.extraPadding, required this.text});

  final bool extraPadding;
  final String text;

  @override
  State<ProblemWidget> createState() => ProblemWidgetState();
}

class ProblemWidgetState extends State<ProblemWidget>

Review comment (suggestion):
While I'm looking at this code, I do have a small suggestion to get rid of the cascade operator at the bottom here. What do you say about removing it, for the sake of readability?

```
children: [
  for (int i = 0; i < 10; i +=1)
    Container(
      color: i.isEven ? const Color(0xFFFF0000) : const Color(0xFF0000FF),
      height: 250.0,
      child: Text('Item $i'),
    ),
  ProblemWidget(extraPadding: extraPadding, text: text),
],
```

Code after:
      expect(tester.widgetList(find.widgetWithText(ProblemWidget, initialLabel)), hasLength(0));
      expect(tester.widgetList(find.widgetWithText(ProblemWidget, newLabel)), hasLength(1));
      expect(semantics, isNot(includesNodeWith(label: initialLabel)));
      expect(semantics, includesNodeWith(label: newLabel));

      semantics.dispose();
    },
  );
}

final Key paddingWidget = GlobalKey();

Widget _buildTestWidget({
  required bool extraPadding,
  required String text,
  required ScrollController controller,
}) {
  return TestWidgetsApp(
    home: Column(
      children: <Widget>[
        Expanded(child: Container()),
        SizedBox(
          height: 500.0,
          child: ListView(
            controller: controller,
            children: <Widget>[
              for (int i = 0; i < 10; i += 1)
                Container(
                  color: i.isEven ? const Color(0xFFFF0000) : const Color(0xFF0000FF),
                  height: 250.0,
                  child: Text('Item $i'),
                ),
              ProblemWidget(extraPadding: extraPadding, text: text),
            ],
          ),
        ),
        Expanded(child: Container()),
      ],
    ),
  );
}

class ProblemWidget extends StatefulWidget {
  const ProblemWidget({super.key, required this.extraPadding, required this.text});

  final bool extraPadding;
  final String text;

  @override
  State<ProblemWidget> createState() => ProblemWidgetState();
}