Skip to content

Refactor has changed the behavior of AnimatedList (Regression) #115040

@b3nni97

Description

@b3nni97

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Compare the width of the colored boxes

Expected results:
The red box (AnimatedList) should not be visible

Actual results:
The red box (AnimatedList) is visible and occupies a part of the Row.

The regression was caused by commit #113793.
#113793 was only supposed to be a refactor, so something must have gone wrong because the behavior changed.

@Piinks

Before #113793 (Expected)
IMG_1610

After
IMG_1609

Code sample
void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Home(),
    );
  }
}

class Home extends StatefulWidget {
  const Home({Key key}) : super(key: key);

  @override
  State<Home> createState() => _HomeState();
}

class _HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Container(
          height: 44,
          color: Colors.blue,
          child: Row(
            children: [
              Container(
                color: Colors.red,
                constraints: BoxConstraints(
                  minWidth: 0,
                  maxWidth: 300,
                ),
                child: AnimatedList(
                  scrollDirection: Axis.horizontal,
                  shrinkWrap: true,
                  itemBuilder: (context, index, animation) {
                    return SizedBox.shrink();
                  },
                  initialItemCount: 0,
                ),
              ),
              Expanded(
                child: Container(
                  color: Colors.purple,
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
Logs
Flutter (Channel master, 3.5.0-12.0.pre.164, on macOS 12.6 21G115 darwin-arm64, locale en-US)

Metadata

Metadata

Assignees

Labels

c: regressionIt was better in the past than it is nowf: scrollingViewports, list views, slivers, etc.found in release: 3.6Found to occur in 3.6frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions