Repository: flutter
Issue: Horizontal `AnimatedSliverList`s do not animate
Labels: framework,a: animation,f: scrolling,has reproducible steps,P2,found in release: 2.10,found in release: 2.13,team-framework,triaged-framework

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a bug or if our documentation doesn't have an answer
     to what you're looking for, then fill out the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->

## Steps to Reproduce

<!-- Please include full steps to reproduce so that we can reproduce the problem. -->

1. Execute `flutter run` on the code sample <!-- (see "Code sample" section below) -->
2. Press the `Add` button to add a lot of `FlutterLogo`s <!-- describe steps to demonstrate bug -->
3. Press the `Change Direction` button... <!-- for example "Tap on X and see a crash" -->

**Expected results:** <!-- what did you want to see? -->

With both horizontal and vertical scroll direction, adding elements is animated. Also, in both directions the content should be scrollable if it overflows.

**Actual results:** <!-- what did you see? -->

Everything works with `scrollDirection == Axis.vertical`, but with `scrollDirection == Axis.horizontal` new elements won't animate in and the content will just overflow, without the user being able to scroll.

<details>
<summary>Code sample</summary>

<!--
      Please create a minimal reproducible sample that shows the problem
      and attach it below between the lines with the backticks.

      To create it you can use `flutter create bug` command and update the `main.dart` file.

      Alternatively, you can use https://dartpad.dev/
      which is capable of creating and running small Flutter apps.

      Without this we will unlikely be able to progress on the issue, and because of that
      we regretfully will have to close it.
-->

[Example on Dartpad](https://dartpad.dev/?id=eef2f849ae3871031b6ff1acacb0b4de)

```dart
// Press add to new elements to the list
// Press the other button to change the direction from vertial to horizontal
// Observe that the animations break and that the content won't scroll either

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.from(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurpleAccent),
      ),
      darkTheme: ThemeData.from(
        colorScheme: ColorScheme.fromSeed(
            seedColor: Colors.deepPurpleAccent, brightness: Brightness.dark)),
      themeMode: ThemeMode.system,
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final _listKey = GlobalKey<SliverAnimatedListState>();
  var _scrollDirection = Axis.vertical;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      persistentFooterButtons: [
        TextButton.icon(
          label: const Text("Add"),
          icon: const Icon(Icons.add),
          onPressed: () => _listKey.currentState?.insertItem(0),
        ),
        TextButton.icon(
            label: const Text("Change direction"),
            icon: const Icon(Icons.rotate_left),
            onPressed: () => setState(() => _scrollDirection =
                _scrollDirection == Axis.vertical
                    ? Axis.horizontal
                    : Axis.vertical))
      ],
      body: CustomScrollView(scrollDirection: _scrollDirection, slivers: [
        SliverAnimatedList(
            key: _listKey,
            itemBuilder: (BuildContext context, int index,
                    Animation<double> animation) =>
                SizeTransition(
                    sizeFactor: animation,
                    child: const FlutterLogo()))
      ]),
    );
  }
}

```

</details>

<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue.
-->

```

```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
Analyzing manage_icons...                                               
No issues found! (ran in 1.7s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
[✓] Flutter (Channel stable, 2.10.4, on Microsoft Windows [Version 10.0.19044.1586], locale de-DE)
    • Flutter version 2.10.4 at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c860cba910 (4 days ago), 2022-03-25 00:23:12 -0500
    • Engine revision 57d3bac3dd
    • Dart version 2.16.2
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at C:\Users\Bent\AppData\Local\Android\sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.11)
    • Visual Studio at O:\Programs\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.11.32228.343
    • Windows 10 SDK version 10.0.17763.0

[✓] Android Studio (version 2020.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.2)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2020.3
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.65.2)
    • VS Code at C:\Users\Bent\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 2.23.0

[✓] Connected device (1 available)
    • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19044.1586]

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
```

</details>

![chrome_2022-03-29_00-25-37](https://user-images.githubusercontent.com/29630575/160497510-a499caf8-a815-4bd5-ab15-096a06578f1e.gif)

<!--
      Consider also attaching screenshots and/or videos to better
      illustrate the issue.

      You can upload them directly on GitHub.
      Beware that video file size is limited to 10MB.
-->